如何在WPF应用程序中使用C#在linq中求和?
我在SQlite中有一个表名JobDetails,其中有10列
I have a table name JobDetails in SQlite and in that i have 10 columns
col1 col2 col3 col4 col5 col6 col7 col8 col9 col10
---- 3000 500 123 528 ---- ---- lose 12/05/2014 ----
---- 4000 600 456 628 ---- ---- profit 13/02/2014 ----
---- 5000 700 789 728 ---- ---- pending 15/06/2013 ----
---- 6000 800 201 828 ---- ---- Completed 01/01/2013 ----
所以现在我将这些列检索到名为CompleteJobDetails的对象中的应用程序代码中,现在我想显示一些结果,例如,我希望使用某些过滤器来显示(col2 + col3 + col4 + col5)的总和,例如我将col8设置为利润",然后应在col8中显示具有利润的记录,这些结果应显示在C#中如何在LINQ中实现此效果,请在帮助"中提供帮助
[edit]已添加代码块-OriginalGriff [/edit]
so now i''m retrieving these columns into my application code in an object called CompleteJobDetails now i want to display some results, such as i want Sum of(col2+col3+col4+col5)to be displayed using some filters i.e., if i give the col8 as "profit" then the records which are having the profit in the col8 those results should be displayed how to acheive this in LINQ in C# please help Thanks in Advance
[edit]Code block added - OriginalGriff[/edit]
引用此链接 [
Hi,
Refer this Link[^]
使用此
var result = yourlist.Where(x => x.col8 == "profit").Sum(x => x.col2 + x.col3 + x.col4+ x.col5);