linq 编译查询,类字段
我如何插入 public var CompiledQuery 编写 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)));
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)));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以尝试。希望这会起作用
you can try. Hope this will work