Unable to create a constant value - only primitive types

前端 未结 4 1850
北荒
北荒 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:02

    You can try the following. It has worked for me as my ProductId os of type nullable.

    IQueryable data = db.matchings.Any(u => product.ProductId.Value == u.ProductId);
    

    or this

    IQueryable data = db.matchings.Any(u => product.ProductId.Value.Equals(u.ProductId));
    

    This worked in my case as the target id is a nullable type as it points to a 1:0 -> * relationship.

提交回复
热议问题