If it is null is because there isn't a relation and not because it is a proxy.
2010/3/16 SedulousTurtle <[email protected]> > Fabio, Graham, and John, thank you for your help. From your posts, I > now understand how the proxies work a little better -- I don't usually > need to worry about replacing them with the proper objects, I just > need to make sure I've accessed all the data I need before the session > is closed. > > However, I think there's also a more subtle issue I'm facing. I get > an error with this code: > ---------- > IList<Instrument> instrumentList; > > using (ISession ses = NHibernateHelper.OpenSession()) > using (ses.BeginTransaction()) > { > instrumentList = ses.CreateQuery(@"FROM > Instrument").List<Instrument>(); > string WontLoad = > instrumentList[0].Location.Institution.ToString(); > > ses.Transaction.Commit(); > } > ---------- > > What Happens: NullException, because I call ToString() on Institution, > which is null. > > What I Expect: Location.Institution is initially null -- because its a > lazy loaded reference stored in a LocationProxy. But I would expect > Institution to be lazily loaded when I cann ToString() on it -- and > yet that's not what I'm observing. > > I've checked the database thoroughly and am very confident that the > data is saved properly. > > My main question: Am I using the NHibernate data retrieval API > improperly, or is there something else going on behind the scenes > (like an error in my XML mapping) that's preventing lazy loading from > operating correctly? > > > > On Mar 15, 6:42 pm, John Davidson <[email protected]> wrote: > > I have found the best performance is to create a separate object for the > > grid and move data from the NHibernate object to the grid object. Instead > of > > using a grid hierarchy I put a second grid on the page to manage the > child > > data and only get the child data after the user makes a selection of the > > parent. Of course the second grid also has its own data object. > > > > Doing it like this there is no issue with proxies or sending too much > > unnecessary data to the web page. It keeps the web page leaner and more > > responsive. > > > > John Davidson > > > > On Mon, Mar 15, 2010 at 4:27 PM, Graham Bunce <[email protected] > >wrote: > > > > > > > > > Sorry, too tired to read the full post and work out what's going on > > > for you but look at this thread that I raised with similar questions: > > > > >http://groups.google.com/group/nhusers/browse_thread/thread/fce0810be. > .. > > > > > A proxy will always be a proxy unless you force replace it (I think) > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "nhusers" group. > > > To post to this group, send email to [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]<nhusers%[email protected]> > <nhusers%[email protected]<nhusers%[email protected]> > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/nhusers?hl=en.- Hide quoted text - > > > > - Show quoted text - > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- Fabio Maulo -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
