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});
精彩评论