Help to convert SQL to LINQ

Asked

Viewed 20 times

-1

I want to convert the code select for a consultation 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 having error:

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

cannot implicitly Convert type 'system.collections.Generic.list "Anonimous type: string Cmp"' to 'system.collections.Generic.list "Anonimous type: string"'

1 answer

0

Try it this way:

List listBpac = modelOff.bpacs.Where(p => p.ibge == oUsuario.ibge) . Select(p => p.Cmp) . Tolist();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.