Hi
I am trying below code but not working
public Int32 subSum(Int32 Id)
{
try
{
var Result = (from t in context.Masters
where t.ID == Id
select new
{
SumCol1 = t.Sum(x => x.weight)
})SingleOrDefault;
return Result;
}
catch (Exception ex)
{
throw ex;
}
}
Thanks
Vishal YelvePosted Oct 2, 2022, 12:13 AM
Try this
Vishal JoshiPosted Oct 3, 2022, 6:10 AM
Hello
Please try below linq query code.
Ramco RamcoPosted Oct 2, 2022, 3:36 AM
Hi
It is giving error Cannot implicitly convert type int? to int. An explicit conversion exists
public Int32 subSum(Int32 Id)
{
try
{
var Result = (from t in context.Masters where t.ID == Id select t).Sum(x => x.SubWeight);
return Result;
}
catch (Exception ex)
{
throw ex;
}
}Thanks