我正在使用 Entity Framework Z Plus 批量更新方法。由于以下问题,我无法继续。实际上,当我给出静态值时,Update 方法效果很好tagName="amir1"
。但是我需要Tagdescription
从 Web 服务或基于的另一个集合中获取tagId
,更新方法不接受扩展方法或任何其他方法来完成我的要求。它的说法
“LINQ to Entities 无法识别方法 'System.String GetTagDescription(Int32)' 方法,并且此方法无法转换为存储表达式。”。
希望我的要求现在很清楚。如果有任何其他方法可以满足我的要求,请指导我。
这是我的代码:
using (var context = new TrialsDBEntities())
{
context.tblTags.Where(x => (tagIdCollection.Contains(x.tagId))).
Update(m => new tblTag { tagDescription = m.tagId.GetTagDescription(), tagName = "amir1" });
}
public static string GetTagDescription(this int i)
{
return "test" + i;
///Replace above line with call to database or web service call
getting some text by giving i as input
}