Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# &引用;DbComparisonExpression需要具有可比较类型的参数;没有明显原因的错误!我怎么修理它?_C#_Linq_Entity Framework_Visual Studio 2012 - Fatal编程技术网

C# &引用;DbComparisonExpression需要具有可比较类型的参数;没有明显原因的错误!我怎么修理它?

C# &引用;DbComparisonExpression需要具有可比较类型的参数;没有明显原因的错误!我怎么修理它?,c#,linq,entity-framework,visual-studio-2012,C#,Linq,Entity Framework,Visual Studio 2012,我得到一份工作 DbComparisonExpression requires arguments with comparable type 以下LINQ to实体查询出错: jobDetails.pdata = db.JobBoardUsers.Where(c => c.id.Equals(jbid)).Select(c => new JobBoardUserProfileModel() { ID = c.id, userid = c.userid, firstname = c.

我得到一份工作

DbComparisonExpression requires arguments with comparable type
以下LINQ to实体查询出错:

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,其余为字符串。此外,该表确实有一个主键

以下是作业板用户档案模型:

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; }
}

似乎一切都很完美。为什么会出现此错误?

我会尝试在Linq语句中使用类型化的ToList():

jobDetails.pdata = db........ToList<JobBoardUserProfileModel>()
jobDetails.pdata=db…….ToList()

否则,它可能返回一个非类型化的列表对象。

jbid的类型是什么?为什么不使用
c.id==jbid
?谢谢你,哈比布,你发现了我的问题。我甚至没有考虑过jbid是一个可能的问题,但可以肯定的是,它是一个字符串,应该根据“userid”而不是“id”进行计算!