我得到“DbComparisonExpression需要具有可比类型的参数”我该如何解决?

时间:2016-12-30 10:07:41

标签: c# asp.net linq

我正在

  

DbComparisonExpression需要具有可比类型的参数

以下LINQ to Entity查询出现

错误:

enter image description here

1 个答案:

答案 0 :(得分:0)

我解决了..问题是x.Id是Guid类型..

        ModelContainer _dataContext = new ModelContainer();
        Guid gId= Guid.Parse(ArtistID);
        var artists = _dataContext.Artists.Select(x => new
        {
            x.FirstName,
            x.LastName,
            x.Id,
            x.Country,
            x.City,
            x.artSpecialty,
            x.approval_status,
            x.ProfilePic,
            x.Nationality,
            x.Website,
            x.Instagram,
            x.FaceBook,
            x.Twitter
        }).Where(x => x.Id.Equals(gId)).FirstOrDefault();