I'm currently playing around with Entity Framework, and have a performance question regarding inner joins.
Which of the following 2 cases is the best based on performance in general?
For simplicity reasons of this example, let's say the there is a 1-to-1 relationship for brothers and sisters.
(1) Inner joins:
EFContext context = new EFContext();
int myId = GetMyOwnId();
Person me = context.People
.Include(p => p.Father)
.Include(p => p.Mother)
.Include(p => p.Brother)
.Include(p => p.Sister)
.Where(p => p.ID == myId);
return me;
(2) Optional multiple queries:
EFContext context = new EFContext();
int myId = GetMyOwnId();
Person me = context.People
.Where(p => p.ID == myId);
if (me.FatherId.HasValue)
me.Father = context.People.Find(me.FatherId);
if (me.MotherId.HasValue)
me.Mother = context.People.Find(me.MotherId);
if (me.BrotherId.HasValue)
me.Brother = context.People.Find(me.BrotherId);
if (me.SisterId.HasValue)
me.Sister = context.People.Find(me.SisterId);
return me;
So which case is the best for every situation?
Or is one better than the other for people without any family, or people with a father and a mother and a brother and a sister?