LINQ-to-NHibernate:不能与FetchMany一起使用Linq Skip()和Take() [英] LINQ-to-NHibernate: Cannot use Linq Skip() and Take() with FetchMany
本文介绍了LINQ-to-NHibernate:不能与FetchMany一起使用Linq Skip()和Take()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这些实体:
public class BlogPost {
public virtual int Id { get; set; }
public virtual IList<Keyword> Keywords { get; set; }
public virtual IList<BlogComment> Comments { get; set; }
}
public class BlogComment {
public virtual int Id { get; set; }
public virtual BlogPost Post { get; set; }
}
public class Keyword {
public virtual int Id { get; set; }
public virtual IList<BlogPost> BlogPosts { get; set; }
}
我想通过它们的Keyword
和comments-count加载BlogPost
的分页列表.所以我试试这个:
I want to load a paged-list of BlogPost
s by their Keyword
s and comments-count. So I try this:
var entities = session.Query<BlogPost>()
.Where(t => t.Published)
.FetchMany(t => t.Keywords)
.OrderByDescending(t => t.UpdatedAt)
.Skip((pageNumber - 1) * pageSize).Take(pageSize)
.Select(t => new {
CommentsCount = t.Comments.Count(),
Post = t
})
.ToList();
但是出现以下错误:
不支持指定的方法.
当我删除.Skip((pageNumber - 1) * pageSize).Take(pageSize)
时,它起作用了!例如
And when I remove .Skip((pageNumber - 1) * pageSize).Take(pageSize)
it works! e.g.
var entities = session.Query<BlogPost>()
.Where(t => t.Published)
.FetchMany(t => t.Keywords)
.OrderByDescending(t => t.UpdatedAt)
// remove the below line
//.Skip((pageNumber - 1) * pageSize).Take(pageSize)
.Select(t => new {
CommentsCount = t.Comments.Count(),
Post = t
})
.ToList();
您是否想通过包含Keyword
来排很多行?感谢您的任何建议.
Have you any idea please to take a number of rows by including Keyword
s? Thanks for any suggestion.
我正在使用NHibernate 3.2 mapping by code
.
推荐答案
3.3.3.GA现在应支持此功能
This should now be supported in 3.3.3.GA
http://sourceforge.net/p/nhibernate /news/2013/03/nhiberate-333ga-released/
这篇关于LINQ-to-NHibernate:不能与FetchMany一起使用Linq Skip()和Take()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文