【发布时间】:2015-11-16 14:47:33
【问题描述】:
最近看了下面的帖子Using a List in a where clause in Entity Framework
我已经尝试过这样做。在示例中,我们有以下代码作为 example:
List<int> docIds = (from d in doc
where d.Tags.All(t => _tags.Contains(t))
select d.id).ToList<int>();
在这里,我们有我的代码:
List<PostOrcamentoServico> lOrcamentos = (from orcamento in db.PostOrcamentoServico
where orcamento.Servicos.All(s => usuario.Clientes.Servicos.Contains(s))
select orcamento).ToList();
但是,我总是收到此错误:
Unable to create a constant value of type 'Servicili.Models.Servicos'. Only primitive types or enumeration types are supported in this context.
我已经尝试过 lamda、LINQ 等。但是,没有任何效果。
这个想法如下:PostOrcamentoServico 就像一个预算,其中必须有一种或多种服务。 另一方面,用户登录,注册指定他可以提供的所有专业服务。因此,当他试图搜索预算时,他只能搜索用户(专业)提供的服务的预算。
- 预算 -> 一对多服务;
- 2.Professioanl -> 一对多服务;
- 搜索 = 专业服务列表中包含服务的所有预算。
【问题讨论】:
标签: c# linq entity-framework list lambda