I'm trying to build a string using ternary operations and pass it to a cell of an Excel file. Here is my code:
ws.Rows[index].Cells[24].Value = i.IliskiliCokluIsler.Count == 0 ?
i.IliskiliMahalle.MahalleAdi != null ? i.IliskiliMahalle.MahalleAdi + " Mahallesi" : "" +
i.IliskiliYerGorme.BulvarCadde != null ? i.IliskiliYerGorme.BulvarCadde + " Cadde" : "" +
i.IliskiliYerGorme.Sokak != null ? i.IliskiliYerGorme.Sokak + " Sokak" : "" +
i.IliskiliYerGorme.BinaNo != null ? "Bina no : " + i.IliskiliYerGorme.BinaNo : "" +
i.IliskiliYerGorme.KatNo != null ? i.IliskiliYerGorme.KatNo + " Kat" : "" +
i.IliskiliIlce.IlceAdi + i.IliskiliSehir.SehirAdi : "";
I know that i.IliskiliIlce.IlceAdi
and i.IliskiliSehir.SehirAdi
and i.IliskiliYerGorme.KatNo
are not null. When I run the code I only get
X Mahallesi
Namely I can't get other entities whether or not they are null. Where am I doing wrong? Is the idea of generating string using ternary operations like that is wrong? How can I do it in the right way? Thanks.