我有以下异常。我检查了设计器,类和机会代码是一个 int。
LINQ to Entities 无法识别方法“Int32 ToInt32(System.Object)”方法,并且该方法无法转换为存储表达式
public tblOpportunity GetOpportunityByCode(string clientCode, string opportunityCode)
{
tblOpportunity opportunity = null;
ConnectionHandler.Invoke<EntityConnection>((connection) =>
{
var context = new xxEntities();
opportunity = context.tblOpportunities.FirstOrDefault<tblOpportunity>(o => o.ClientCode == clientCode && o.OpportunityCode == Convert.ToInt32(opportunityCode));
});
return opportunity;
}
}
public partial class tblOpportunity
{
public int OpportunityCode { get; set; }