Linq查询得到统计

时间:2011-05-07 05:54:33

标签: linq

id | IsEnquiry  | 
=================
1      true
2      false
3      false
4      true

如何使用Linq查询获取IsEnquiry = true的id计数

请帮助我编写查询。

谢谢, 巴拉斯

4 个答案:

答案 0 :(得分:37)

int count = (from row in db.Table
             where row.IsEnquiry == true
             select row).Count();

答案 1 :(得分:26)

试试这个

var count = db.Table.Where(x=>x.IsEnquiry).Count()

答案 2 :(得分:0)

尝试以下代码:

int count = (from tableObj in TableName 
             where tableObj
             .Website == "http://mywebsite.com" 
             select tableObj 
             .Website).Count()

答案 3 :(得分:0)

尝试一下:

int count = (from row in db.Table
             where row.IsEnquiry == true
             select row.id).Count();
相关问题