Ramco Ramco

Ramco Ramco

  • 1.1k
  • 1.2k
  • 98.1k

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)