Click here to Skip to main content
15,906,094 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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    ----


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]
Posted
Updated 28-May-14 23:27pm
v2

Hi,

Refer this Link[^]
 
Share this answer
 
Use this
C#
var result = yourlist.Where(x => x.col8 == "profit").Sum(x => x.col2 + x.col3 + x.col4+ x.col5);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900