Unable to create a constant value - only primitive types

前端 未结 4 1858
北荒
北荒 2020-11-30 08:25

Two simple queries - the exception occurs in :

matchings.Any(u => product.ProductId == u.ProductId)

What is wrong? If I write true

4条回答
  •  囚心锁ツ
    2020-11-30 09:08

    I was facing the same issue when writing the following query using collection and EF tables:

    var result = (from listItem in list
                  join dbRecord in Context.MY_TABLE
                      on listItem.MyClass.ID equals dbRecord.ID
                  select new { dbRecord, listItem.SomeEnum }).ToList();
    

    I could solve it by changing the source order in in:

    var result = (from dbRecord in Context.MY_TABLE
                  join listItem in list
                      on dbRecord.ID equals listItem.MyClass.ID
                  select new { dbRecord, listItem.SomeEnum }).ToList();
    

提交回复
热议问题