Ramco Ramco

Ramco Ramco

  • 439
  • 3.4k
  • 530k

Sum of Field using Linq

Oct 1 2022 5:48 PM

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


Answers (3)