简体   繁体   中英

Linq - group and get list of objects

I have a list of L_CabecDocumento and each one of them has a L_CabecJob . I want to get all unique L_CabecJob from each and every L_CabecDocumento (i have a Where condition).

The problem is that i can't cast it to a List<L_CabecJob>() What am i doing wrong? 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 ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM