I call some date in my database using entity frame work. but My below code giving this error
LINQ to Entities does not recognize the method \'SchoolBreifcase
You need to create a variable to refer to compliance[i].ComplianceId
then use it later.
for (int i = 1; i < compliance.Count; i++)
{
var complianceId = compliance[i].ComplianceId;
financialCompliance = datamodel.FinancialCompliances.Where(f => f.ComplianceId == complianceId ).SingleOrDefault();
if (compliance.Count == i)
{
return financialCompliance;
}
}
It's about the compliance[i].ComplianceId
. Create a variable first:
var id = compliance[i].ComplianceId;
financialCompliance = datamodel.FinancialCompliances
.Where(f => f.ComplianceId == id).SingleOrDefault();