[英]Linq - group and get list of objects
I have a list of L_CabecDocumento
and each one of them has a L_CabecJob
. 我有一个L_CabecDocumento
列表,每个列表都有一个L_CabecJob
。 I want to get all unique L_CabecJob
from each and every L_CabecDocumento
(i have a Where
condition). 我想所有的独特L_CabecJob
从每L_CabecDocumento
(我有一个Where
条件)。
The problem is that i can't cast it to a List<L_CabecJob>()
What am i doing wrong? 问题是我无法将其List<L_CabecJob>()
转换为List<L_CabecJob>()
我在做什么错? Thanks 谢谢
var lista = (from d in appADO.L_CabecDocumento
where d.L_TipoEntidadeId == 2 && d.Entidade == fornecedor
group d by d.CabecJob into c
select c.Key ).ToList() ;
return (List<L_CabecJob>)lista;
instead - 相反-
return (List<L_CabecJob>)lista;
use - 采用 -
return lista.Cast<L_CabecJob>();
next time english variables might help us understand youre code better ;) 下次,英语变量可能会帮助我们更好地了解您的代码;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.