0

I have two tables which are in a relationship. They are called tblX and tblY.

var x = (from v in db.tblX select v).First();

Now x has these properties:

x.name
x.id
x.tblY

tblY has these properties: idY, nameY.

After I use the linq statement above, I can get to idY without making a join. I can access x.tblY.idY and x.tblY.nameY. Is it ok if I access them like this? Is it a good programming practise?

petko_stankoski
  • 10,459
  • 41
  • 127
  • 231

1 Answers1

2

tblY's properties will be loaded lazily. It is fine unless you do this operation repeteadly for big numbers of tblX objects. Than you might consider eager loading.

Related: Entity Framework - what's the difference between using Include/eager loading and lazy loading?

Community
  • 1
  • 1
emregon
  • 388
  • 1
  • 7
  • 18