Select net value from sum of 2 columns in linq
Hi all,
I have a table called table 1 ,in that table below columns are available
ID currentqty newqty
1 null null
2. 8. 4
3. 34. 24
4. Null. Null
Need to select sum(currentqty)-sum(newqty)
In linq c#

Farhan AhmedPosted Aug 13, 2020, 11:33 AM
Navaneeth KrishnanPosted Aug 13, 2020, 10:22 AM
Jaimin ShethiyaPosted Aug 13, 2020, 3:41 AM
try to below query
var totCurrentQty = context.TableName.Sum(x=> x.CurrentQty ?? 0);
var totNewQty = context.TableName.Sum(x=> x.NewQty ?? 0);
Thanks
Jignesh KumarPosted Aug 10, 2020, 9:47 PM