我正在
DbComparisonExpression requires arguments with comparable type
以下LINQ to Entity查询出现错误:
jobDetails.pdata = db.JobBoardUsers.Where(c => c.id.Equals(jbid)).Select(c => new JobBoardUserProfileModel() { ID = c.id, userid = c.userid, firstname = c.firstname, lastname = c.lastname, PostalCode = c.passcode, phone = c.phone, JobDescription = c.desiredjobtitle, resumetext = c.resumetext, savedresume = c.savedresume }).ToList();
除了ID(Int)之外,所有其他列都是Varchar。在EF(模型浏览器)中,ID列显示为Int32,其余为String。此外,该表确实有一个主键。
以下是 JobBoardUserProfileModel模型:
public class JobBoardUserProfileModel
{
public int ID { get; set; }
public string userid { get; set; }
public string firstname { get; set; }
public string lastname { get; set; }
public string PostalCode { get; set; }
public string phone { get; set; }
public string JobDescription { get; set; }
public string savedresume { get; set; }
public string resumetext { get; set; }
}
似乎一切都完美对齐。为什么我会收到此错误?
答案 0 :(得分:-1)
我尝试在Linq语句中使用Typed ToList():
jobDetails.pdata = db........ToList<JobBoardUserProfileModel>()
如果没有它,它可能会返回一个无类型的List对象。