Help convert SQL into LINQ

-1

I want to convert the code select to a query LINQ

SELECT bpac.cmp FROM bpac
union
SELECT bpai.cmp FROM bpai
group by cmp
order by cmp desc

I'm trying to get the first table and I'm already getting error:

List<string> listaBpac = modelOff.bpacs.Where(p => p.ibge == oUsuario.ibge)
                                    .Select(p => new { p.cmp })
                                    .ToList();
  

can not implicitly convert type 'system.collections.generic.list "anonimous type: string cmp"' to 'system.collections.generic.list "anonimous type: string"'

    
asked by anonymous 02.10.2018 / 15:43

1 answer

0

Try this:

ListBpac List = modelOff.bpacs.Where (p => p.ibge == or User.ibge)                                     .Select (p => p.cmp)                                     .ToList ();

    
02.10.2018 / 16:08