HI lets see how to fetch records in LINQ based on the where condition specified.
Example:
var query = from r in dtSampleDataTable.AsEnumerable()
where r.Field<string>("Salary") == "1000"
select r;
if (query.Count() > 0)
{
DataTable dt1 = query.CopyToDataTable(); //fetching filtered rows to a new datatable.
object sumSalary = dt1.Compute("Sum(Salary)", "");
}
string s = sumSalary.ToString();
Thanks for the post and have a great day..
ReplyDeleteby PSY 201 Week 9