LinqKit: AsExpandable not working

冷暖自知 提交于 2019-12-24 00:58:16

问题


Code:

public static GetRows()
        {

            var to_ret = db.TableRows.Select(x=> new TableRowModel(
            {
                TableRowId = x.TableRowId,
                Type = x.Type,
                Name = x.Name,
                CreatedAt = x.CreatedAt,
                ModifiedAt = x.ModifiedAt,
                Enums = x.Enums.AsExpandable().Select(y => y.ToEnumModel())
            });
            return to_ret;
        }

public static EnumModel ToEnumModel(this Enum x)
        {
            var to_ret = new EnumModel()
            {
                CFPId = x.CFPId,
                CreatedAt = x.CreatedAt,
                ModifiedAt = x.ModifiedAt,
            };
            return to_ret;
        }

Running GetRows gives error saying:

LINQ to Entities does not recognize the method 'System.Linq.IQueryable1[Test.Models.Enum] AsExpandable[Enum](System.Linq.IQueryable1[Test.Models.Enum])' method, and this method cannot be translated into a store expression.

Even tried putting AsExpandablelike db.TableRows.AsExpandable().Select. Doesn't work.

来源:https://stackoverflow.com/questions/46946370/linqkit-asexpandable-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!