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

后端 未结 2 406
傲寒
傲寒 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;
        }
    }
    
    0 讨论(0)
  • 2021-01-02 05:32

    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();
    
    0 讨论(0)
提交回复
热议问题