If you are going to create a list of DTO *with* the property value, you will
have to fetch it eager. ("fetch all properties" in hql)
if you are going to create a list of dto *without* the property value, you
simply don't call and don't do anything with the property.Maintain lazy loading capabilities in the dto is a crazy idea, so you will have to choose one way. 2010/9/8 taber loveless <[email protected]> > The way Ive solved this is to perform some custom mapping from the DAO > to the DTO so I can check IsPropertyInitialized: > > public static DTO.Blog CreateFrom(DAO.Blog blog) > { > return new DTO.Blog() > { > Id = blog.Id, > Author = blog.Author, > Date = blog.Date, > Tags = blog.Tags, > //Dont cause to be loaded from DB if we dont already have > value > (must eagerly be eagerly loaded) > Content = NHibernateUtil.IsPropertyInitialized(blog, > "Content") ? > blog.Content : null > }; > } > > On Sep 8, 1:22 pm, taber loveless <[email protected]> wrote: > > I attempted to use a lazy-loaded field for the 'content' (lazy- > > properties) but couldnt > > find a way to remove/nullify the proxy so it was not hydrated > > automatically (for all results) when mapping to DTO. > > > > On Sep 8, 11:40 am, José F. Romaniello <[email protected]> wrote: > > > > > with nhibernate 3.. There is a new feature, Lazy propertieshttp:// > ayende.com/Blog/archive/2010/01/27/nhibernate-new-feature-lazy... > > > > > 2010/9/8 taber loveless <[email protected]> > > > > > > Goal: only hydrate 'content' property for specific calls i.e.: > > > > List<Blogs> GetBlogOverview() //only meta-data > > > > List<Blogs> GetBlogContent(blog Id) //also load content > > > > > > Table-Blog > > > > id > > > > dateTime //meta-data > > > > author //meta-data > > > > tags //meta-data > > > > content //large data (text/binary/varchar(max)/etc) > > > > > > I attempted to use a lazy-loaded field for the 'content' but couldnt > > > > find a way to remove/nullify the proxy so it was not hydrated > > > > automatically (for all results) when mapping to DTO. > > > > > > One way is to have 2 differnt DAO's (1 with only meta data, 1 with > > > > meta-data and content) but this is a common (anti)pattern in our > > > > domain and Id rather not have to manage 2 dao's every time. > > > > > > Please provide suggestions or references to solutions for similar > > > > scenarios :) > > > > > > -- > > > > 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. > > -- > 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. > > -- 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.
