代码
using (TimeTableEntities obj = new TimeTableEntities())
{
var dataM=obj.LoginAccesses.Where(i =>(i.Salutation + ' ' + i.Fname + ' ' + i.Lname) == fname).ToList();
foreach(var countTemp in dataM)
{
//mycode
}
}
异常
"Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context."
当我尝试没有where子句时,它对我来说很好,但当我添加它显示在Exception上面的地方
提前致谢
答案 0 :(得分:0)
在您的实体中创建新的Proprty
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public string MyCombinationData{
get{
return Salutation + ' ' + Fname + ' ' + Lname
}
}
并在您的查询中使用此:
var dataM=obj.LoginAccesses.Where(i =>i.MyCombinationData == fname).ToList();