1

如何 插入public var compiledQuery write 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)));
4

1 回答 1

1

你可以试试。希望这会奏效

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});
于 2011-05-15T18:26:10.510 回答