开发者

linq compiled query, class field

How can I insted of 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});

When I try it like this i get error: Only parametar less constructor are suported

 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)));


you can try. Hope this will work

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});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜