当行块C = 0时,还有其他比较Id的方法而不是Id.ToString().Contains(Id.Tostring())
if (events_sL.Count != 0)
{
int c;
for (c = 0; c < events_sL.Count; c++)
{
var a = (from s in db.Booked_s
where s.IdEvent.ToString().Contains(events_sL[c].EventId.ToString())
select s).ToList();
}
}
将错误抛出
Linq to Entities没有认识到这种方法 WebApplication.Models.Event get_Item(Int32)
答案 0 :(得分:0)
实际上,您正在尝试将events_sL[c].EventId.ToString()
转换为SQL,但LINQ提供程序并不知道如何执行此操作。您只想在内存中评估该值,然后在查询中使用结果:
var foo = events_sL[c].EventId.ToString();//todo give better name
var a = (from s in db.Booked_s
where s.IdEvent.ToString().Contains(foo)
select s).ToList();