Operator '==' cannot be applied to operands of type 'System.Guid' and 'string' in linq to entity

前端 未结 7 734
礼貌的吻别
礼貌的吻别 2020-12-18 21:12

I am getting this error \'Operator \'==\' cannot be applied to operands of type \'System.Guid\' and \'string\'\' in linq to entityframework below code. in the below code Cus

相关标签:
7条回答
  • 2020-12-18 22:08

    That's because you can't equate a Guid and a string.

    So you need to convert the Guid to string first. Normally I'd suggest:

    where C.CustomerId.ToString().Equals(customerProfileId)
    

    but ToString() doesn't exist in Linq to Entities.

    The answer to this question - Problem getting GUID string value in Linq-To-Entity query - will probably help.

    0 讨论(0)
提交回复
热议问题