我正在尝试从 LINQ2SQL 切换到 EF ...我收到以下错误,其中一些代码最初与 LINQ2SQL 一起使用并且似乎可以正确编译:
Csla.DataPortalException: DataPortal.Fetch failed (LINQ to Entities does not recognize the method 'MyApp.Logic.UserInfo FetchUserInfo(MyApp.Data.User)' method, and this method cannot be translated into a store expression.)
---> Csla.Reflection.CallMethodException: DataPortal_Fetch method call failed
---> System.NotSupportedException: LINQ to Entities does not recognize the method 'MyApp.Logic.UserInfo FetchUserInfo(MyApp.Data.User)' method, and this method cannot be translat...
这是代码:
var data = query.Select(row => UserInfo.FetchUserInfo(row));
this.AddRange(data);
我正在尝试读取数据列表并将实体加载到我的类中。我是 EF 的新手,只是觉得我忽略了一些东西。
任何帮助,将不胜感激!
对于那些感兴趣的人,解决方案是:
var data = query.AsEnumerable().Select(UserInfo.FetchUserInfo);