LINQ 编译的查询,类字段



我怎样才能代替公共var编译查询Func <MYEntities,string,???>

    public var compiledQuery = CompiledQuery.Compile((AddresEntities ctx, string name) =>
    from x in ctx.User
    where x.Name.Contains(name)
    select new { x.Name, x.Phone});

当我像这样尝试时,我得到错误:只支持参数较少的构造函数

 public static   Func<AddresEntities, string, IQueryable<MYClass>> compiledQuery =
           CompiledQuery.Compile((AddresEntities ctx, string name) =>
                                 (from x in ctx.Users
                                  where x.Name.Contains(name)
                                   select new MYkontakt( x.Name, x.Phone)));

你可以试试。希望这会起作用

IEnumerable<yourType> compiledQuery = CompiledQuery.Compile((AddresEntities ctx, string name) =>
from x in ctx.User
where x.Name.Contains(name)
select new yourType { x.Name, x.Phone});

相关内容

  • 没有找到相关文章

最新更新