开发者

Can some one help me to conver it into LINQ i m using Entity Framework

select ForumCategories.ID , ForumCategories.Title , ForumCategories.DateCreated, CO = ( select COUNT(*) from ForumSubCategories where Forum开发者_开发知识库SubCategories.CategoryID_FK = ForumCategories.ID) from ForumCategories


var q = from fc in Context.ForumCategories
        select new 
        {
            Id = fc.ID,
            Title = fc.Title,
            DateCreated = fc.DateCreated
            CO = fc.ForumSubCategories.Count()
        };
return q;

The "join" (subquery) is implicit; it's defined in the relationship between ForumCategories and ForumSubCategories in your model. Using this syntax, the call to Count() will be done on the DB server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜