Question

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)));
Was it helpful?

Solution

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});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top