1
我怎样才能insted的公共变种compiledQuery写Func键< MYEntities,串,???>LINQ编译的查询,类别字段
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)));
它不起作用。 – 2011-05-16 07:07:50
请给出您的错误 – anishMarokey 2011-05-16 07:09:01
无法初始化类型'Database.User_Services.MyUser'集合初始化程序 ,因为如果它不是IEnumerable类型,它不会实现'System.Collections.IEnumerable' – 2011-05-16 07:46:27