Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linq查询以获取计数_Linq - Fatal编程技术网

Linq查询以获取计数

Linq查询以获取计数,linq,Linq,如何使用Linq查询获得IseQuery=true的id计数 请帮我写查询 谢谢, 巴拉斯试试这个 int count = (from row in db.Table where row.IsEnquiry == true select row).Count(); 请尝试以下代码: var count = db.Table.Where(x=>x.IsEnquiry).Count() 试试这个: int count = (from ta

如何使用Linq查询获得IseQuery=true的id计数

请帮我写查询

谢谢, 巴拉斯试试这个

int count = (from row in db.Table
             where row.IsEnquiry == true
             select row).Count();
请尝试以下代码:

var count = db.Table.Where(x=>x.IsEnquiry).Count()
试试这个:

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

桌子你真的是指LINQ还是指SQL?LINQ用于查询语言元素(对象集合)而不是数据库表。@IanNorton,听说过LINQ to SQL吗?这是LINQ扩展中的Lambda表达式,不是LINQ查询。贾里德·哈丁的回答是一个Linq查询的例子。哦,伟大的安东尼,谢谢你澄清这一点。我坐在这里盯着它看,就像一只玩纵横填字游戏的猴子,想知道如何应用它:
var count=db.Table.count(x=>x.isequiry)这与问题有什么关系?如果每行中都有大量数据,那么更有效的方法是选择一些简单的数据,而不是整行。例如(从数据库表中的行,其中row.isequiry选择1).Count();
int count = (from tableObj in TableName 
             where tableObj
             .Website == "http://mywebsite.com" 
             select tableObj 
             .Website).Count()
int count = (from row in db.Table
             where row.IsEnquiry == true
             select row.id).Count();