How to COUNT rows within EntityFramework without loading contents?

后端 未结 7 1352
一个人的身影
一个人的身影 2020-11-29 17:56

I\'m trying to determine how to count the matching rows on a table using the EntityFramework.

The problem is that each row might have many

7条回答
  •  半阙折子戏
    2020-11-29 18:36

    I think this should work...

    var query = from m in context.MyTable
                where m.MyContainerId == '1' // or what ever the foreign key name is...
                select m;
    
    var count = query.Count();
    

提交回复
热议问题