1
I’m trying to use a Union select, in an Entity framework, but I’m not able to gather the information, follow how I’m trying to do:
var un = _context.CaixaMovimentos.Select(c => new
{
c.Data, c.Hora, Histórico = c.Historico, c.Forma
}).ToList()
.Union(_context.ContasReceber.Select(r => new
{
r.DataPagamento, Hora = r.DataPagamento, r.Observacao, r.FormaPagamento
}).ToList()).Union(_context.ContasApagar.Select(p => new {
p.DataPagamento, Hora = p.DataPagamento, p.Obs, p.FormaPagamento
}).ToList());
Only it returns me error. How can I do ?
I managed to solve it by doing it this way:
var un = _context.CaixaMovimentos.Select(c => new
{
Data = c.Data,
Hora = c.Hora,
Histórico = c.Historico,
Valor = c.Valor,
Forma = c.Forma
}).ToList()
.Union(_context.ContasReceber.Select(r => new
{
Data = r.DataPagamento,
Hora = r.DataPagamento,
Histórico = r.Observacao,
Valor = r.ValorPago,
Forma = r.FormaPagamento
}).ToList()).Union(_context.ContasApagar.Select(p => new
{
Data = p.DataPagamento,
Hora = p.DataPagamento,
Histórico = p.Obs,
Valor = p.ValorPago,
Forma = p.FormaPagamento
}).ToList());
But I don’t know how to relate these fields to my table.
Hello, Mariana. What error? Add the error you are experiencing by editing your question.
– Dherik
Managed to solve, thanks @Dherik, I was not understanding how it worked, you know tell me how I can play on the table the dice ?
– Mariana