1
I’m doing the union, in one of select i need to make a condition to appear in the correct way. To not keep appearing blank values.
I tried to do it this way:
      Documento = (c.FaturaContasReceberP.NotaFiscal != null ? "Fat. NFSe: " + c.FaturaContasReceberP.NotaFiscal : null +
         c.FaturaContasReceberP.NotaFiscalProdutos != null ? " NFe: " + c.FaturaContasReceberP.NotaFiscalProdutos : null).Trim()
But it does not work as expected, here is the complete part of the code:
 var FR = db.FaturaContasReceber.Include(c => c.FaturaContasReceberP).Where(c => c.Quitado == true && c.Caixa == false && c.BancoId == id).Select(c => new BancoList
        {
            Id = c.Id,
            Data = c.DataPagamento,
            Valor = c.Total,
            Tipo = "C",
            Documento = (c.FaturaContasReceberP.NotaFiscal != null ? "Fat. NFSe: " + c.FaturaContasReceberP.NotaFiscal : null +
         c.FaturaContasReceberP.NotaFiscalProdutos != null ? " NFe: " + c.FaturaContasReceberP.NotaFiscalProdutos : null).Trim()
        }).ToList();
How to solve, I need it to appear the field if it has filled in, it may occur of only one of the two being filled in, or of the two.
To my knowledge, C# does not accept a question mark within the
if, may have some other special character to replace it– riki481
Sorry, I edited the question, I’m not using the
if– Mariana
tries to put the operation in parentheses, like
("Fat. NFSe: " + c.FaturaContasReceberP.NotaFiscal).. c# may be getting lost with the signs– rLinhares
@Since it only appears the values of Nfse, even if Nfe is not
nullit does not appear, and when only Nfe has value, theDocumentoempty.– Mariana