我有一个看起来像这样的对象模型(伪代码):
class Product {
public ISet<Product> Recommendations {get; set;}
public ISet<Product> Recommenders {get; set;}
public ISet<Image> Images {get; set; }
}
Run Code Online (Sandbox Code Playgroud)
当我加载给定的产品并想要显示其推荐的图像时,我遇到了N + 1问题.(建议是延迟加载的,然后循环调用每个的.Images属性.)
Product -> Recommendations -> Images
Run Code Online (Sandbox Code Playgroud)
我想要做的是急切地加载图表的这个特定部分,但我无法弄清楚如何做到这一点.我可以热切地加载建议,但不能加载他们的图像.这是我一直在尝试的,但它似乎不起作用:
//get the IDs of the products that will be in the recommendations collection
var recommendedIDs = QueryOver.Of<Product>()
.Inner.JoinQueryOver<Product>(p => p.Recommenders)
.Where(r => r.Id == ID /*product we are currently loading*/)
.Select(p => p.Id);
//products that are in the recommendations collection should load their
//images eagerly
CurrentSession.QueryOver<Product>()
.Fetch(p => p.Images).Eager
.Where(Subqueries.WhereProperty<Product>(p …Run Code Online (Sandbox Code Playgroud) 我有一个非常奇怪的问题.
我正在使用Twitter Bootstrap 2.我在页面上有一个模态对话框,我这样打开:
$('#rights-dialogue).modal();
我还在Object.prototype对象中添加了一个自定义函数,如下所示:
Object.prototype.foo = function (a) {};
当x在多种形式对话按钮被点击,对话关闭,但黑色的背景仍然存在,我在jQuery的事件处理代码得到一个奇怪的jQuery的错误:
Uncaught TypeError: Cannot read property 'origType' of undefined
如果我从我的foo()函数中删除所有参数,我不会得到这个错误,一切正常.
这是一个说明问题的jsfiddle:http://jsfiddle.net/nicholascloud/r6T8z/5/.
我不知道这里发生了什么.
编辑:我注意到的其他一些事情.
Object.prototype上的方法名称似乎并不重要.任何带参数的方法都会导致此错误.如果添加的方法没有参数,则不会发生错误.
当jQuery keyup.dismiss.modal从DOM 分离事件侦听器时,会发生此错误.
我已经用jQuery 1.7.1和1.7.2确认了这个错误,但我怀疑它是一个Twitter Bootstrap问题而不是jQuery本身.
这是约.我正在使用的代码.
public class Note {
public virtual Customer Customer { get; set; }
public virtual User User { get; set; }
public ICollection<NoteComment> Comments { get; set; }
}
public class NoteComment {
public virtual User User { get; set; }
}
public class User {
public ICollection<Note> Notes { get; set; }
}
public class Customer {}
// --------------------------------------
public class OurDataContext {
private void ConfigureNotes(DbModelBuilder modelBuilder) {
modelBuilder.Entity<Note>()
.HasRequired<User>(n => n.User)
.WithMany(u => u.Notes)
.Map(a => a.MapKey("UserId"));
modelBuilder.Entity<Note>() …Run Code Online (Sandbox Code Playgroud) entity-framework circular-reference code-first sql-server-ce ef-code-first