我如何计算此 linq to sql 查询的总和?
How can i calculate sum of this linq to sql query?
我是 linq to sql 的初学者,我使用 c# linq to sql 并编写了这个查询:
var query_find = (from t in behzad.Interconnect_Traffic_Analysis_Details
where t.FILEID == FILE_ID && t.code_operator.Trim() == item.code_operator.Trim()
select new { t.moddat }).ToList();
我想计算 t.moddat
列的总和,如何将此查询转换为对值求和?谢谢。
t.moddat
是 nvarchar(max)
数据类型并保存到该双数据类型值中。
试试这个
var query_find = (from t in behzad.Interconnect_Traffic_Analysis_Details
where t.FILEID == FILE_ID && t.code_operator.Trim() == item.code_operator.Trim()
select new
{
sum= t.moddat
}).ToList();
var sum= query_find.Sum(x => Convert.ToDouble(x.sum));
我是 linq to sql 的初学者,我使用 c# linq to sql 并编写了这个查询:
var query_find = (from t in behzad.Interconnect_Traffic_Analysis_Details
where t.FILEID == FILE_ID && t.code_operator.Trim() == item.code_operator.Trim()
select new { t.moddat }).ToList();
我想计算 t.moddat
列的总和,如何将此查询转换为对值求和?谢谢。
t.moddat
是 nvarchar(max)
数据类型并保存到该双数据类型值中。
试试这个
var query_find = (from t in behzad.Interconnect_Traffic_Analysis_Details
where t.FILEID == FILE_ID && t.code_operator.Trim() == item.code_operator.Trim()
select new
{
sum= t.moddat
}).ToList();
var sum= query_find.Sum(x => Convert.ToDouble(x.sum));