-1
I have the following consultation:
var recs = (from p in _db.Fichas
.Include(c => c.Tipo01)
.Include(c => c.Tipo02)
.Include(c => c.Tipo03)
.Include(c => c.Pessoa01)
.Include(c => c.Pessoa02)
.Include(c => c.Pessoa03)
.AsNoTracking()
where p.Id == 100
select p).FirstOrDefault();
Based on the above query, I am getting and reading (I believe mistakenly) the values of the following properties:
var nome1 = recs.Pessoa01 != null ? recs.Pessoa01.Nome : null;
var nome2 = recs.Pessoa02 != null ? recs.Pessoa02.Nome : null;
var nome3 = recs.Pessoa03 != null ? recs.Pessoa03.Nome : null;
var tip1 = recs.Tipo01 != null ? recs.Tipo01.ModeloA : null;
var tip2 = recs.Tipo02 != null ? recs.Tipo02.ModeloA : null;
Some colleague could help me and show me a more decent way to perform this task?
Hug Hugo
Good morning, Leandro. Thank you very much for your feedback. I am giving maintenance on third party system. In fact, to save development lines, I thought of something as a loop to read the properties and entities. For example, instead of having to get the "Name" of the entities "Personal,01, Personal," etc.".
– Hugo
Something like that: rec. Person(i+1). Name Got it?
– Hugo