LinqKit: AsExpandable not working

2019-07-15 21:20发布

问题:

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.

标签: c# linq linqkit