I am using nhibernate and I have a question.
Say I have an object(ObjectA) that has some relationship to another object(ObjectB).
ObjectA -> TableA
ObjectB -> TableB
Now I do a query and get back results from TableA and now it’s in ObjectA.
If I did this
int b = ObjectA.ObjectB.ColumnA;
it would go off and fire a query right? Since it is doing lazy loading.
what happens if I did this
int b1 = ObjectA.ObjectB.ColumnA;
int b2 = ObjectA.ObjectB.ColumnA;
int b3 = ObjectA.ObjectB.ColumnA;
int b4 = ObjectA.ObjectB.ColumnA;
this is all in the method method one after another. Would you go and do 5 queries or would it just do one?
How about if I did this
int b1 = ObjectA.ObjectB.ColumnA;
string b2 = ObjectA.ObjectB.ColumnB;
would this fire off 2 queries or one?
All those methods result in just one call, to load ObjectB.
After that, it’s in memory; why would it go to the DB again?