在WCF RIA中的linq语句中调用存储过程做条件判断,提示无法识别改函数,该怎么解决
在WCF RIA中的linq语句中调用存储过程做条件判断,提示无法识别改函数
我在WCF RIA中的linq查询语句中调用存储过程来作为where的条件判断,在运行时提示无法识别该存储过程。有没有大侠遇到过这种问题,劳烦解答!
代码如下:
错误消息如下:
------解决方案--------------------
(from c in this.ObjectContext.proc_Vehiclerights(userName)
where s.Vehiclenum == c.Vehiclenum
select c
).Count() > 0
这些可以简化成一句:
this.ObjectContext.proc_Vehiclerights(userName).AsEnumerable().Any(c=>s.Vehiclenum == c.Vehiclenum)
我在WCF RIA中的linq查询语句中调用存储过程来作为where的条件判断,在运行时提示无法识别该存储过程。有没有大侠遇到过这种问题,劳烦解答!
代码如下:
public IQueryable<ProMainenance> getMyProMainenances(string userName)
{
return (from s in this.ObjectContext.ProMainenances
where s.auditID == userName ||
(from c in this.ObjectContext.LoginUsers
where c.ZT == true && c.InUserID == userName && c.UserId == s.auditID
select c).Count() > 0 ||
isAvaiable(s.Vehiclenum)
(from c in this.ObjectContext.proc_Vehiclerights(userName)
where s.Vehiclenum == c.Vehiclenum
select c
).Count() > 0
select s);
}
错误消息如下:
linq
无法转为存储表达式
不识别方法
------解决方案--------------------
(from c in this.ObjectContext.proc_Vehiclerights(userName)
where s.Vehiclenum == c.Vehiclenum
select c
).Count() > 0
这些可以简化成一句:
this.ObjectContext.proc_Vehiclerights(userName).AsEnumerable().Any(c=>s.Vehiclenum == c.Vehiclenum)