Monday, 12 September 2022

Aggregate Function Entity Framework C#

 Sum 

Get Sum of amount by a select filter using C# MVC Entity Framework


First Method

 dbConnection db = new dbConnection();
 int InvoiceAmount = db.Bill.Where(x => x.CID == 123).Select(i => i.Amount).Sum();


Second Method


data.Where(x => x.msg == "paid").Sum(y => Convert.ToInt32(y.Amount));


Next Topic

No comments:

Post a Comment