LINQ to Entities does not recognize the method and this method cannot be translated into a store expression

后端 未结 2 411
傲寒
傲寒 2021-01-02 05:01

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

2条回答
  •  旧巷少年郎
    2021-01-02 05:13

    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;
        }
    }
    

提交回复
热议问题