1
When performing the query in a given table, numOrc
is a list that may contain one or more values.
So I needed to concatenate these values into one string
, using ;
as a limiter.
So I tried:
var model = (from s in db.Vendas_pedidos
join p in db.Cliente_contatos on s.idContato equals p.id_cliente_contato into _p
from p in _p.DefaultIfEmpty()
join t in (
from t1 in db.Vendas_itens
group t1 by t1.numeroPedido into g
select new
{
numeroPed = g.Key,
valorTotal = g.Sum(x => x.valortotal),
maxStatus = g.Max(x => x.status),
tipoMaterial = g.Max(x => x.tipoElemento),
numOrc = g.Select(x => x.numOrc)
}
) on s.id equals t.numeroPed
where s.idCliente == codCliente
select new
{
id = s.id,
dataCad = s.dataEmissao,
contato = (p.nome + " " + p.sobrenome),
valorTotal = ("R$ " + t.valorTotal.ToString()),
dataSolicCotacao = s.dataSolicCotacao,
status = t.maxStatus,
tipoMaterial = (t.tipoMaterial.ToString().Equals("5") ? "Serviço" : "Venda").ToString(),
numOrc = t.numOrc.ToList().Aggregate((a, b) => a + ";" + b)
}).OrderByDescending(x => x.id).ToList();
But when executing the error is returned: