1
我对此非常困惑。我正尝试将的帖子变为可变的方法。我该如何去这样做:Linq to Entities:我如何将IQueryable传递给方法
var posts = from p in context.post
where (p.post_isdeleted == false && (object.Equals(p.post_parentid, null))
select new
{
p.post_date,
p.post_id,
FavoriteCount = (from f in context.favorites
where f.post.post_id == p.post_id
select new { f }).Count()
};
posts = QuestionList.FilterQuestion(posts, sort);
//the problem is here
//IQueryable is not the right type for posts. What type do I put in there
private static IQueryable FilterQuestion(IQueryable p, string sort)
{
Linq查询可能会有所简化。例如,如果你的对象模型设置正确,'FavoriteCount = p.post.favorites.count()'。 – 2010-02-08 19:58:21