> To do it you dot't need anything else than > NHibernateUtil.Initialize(entity);
Thanks Fabio, that's all I wanted to know :-) On Sep 24, 1:35 am, Fabio Maulo <[email protected]> wrote: > I think you should re-order your thought.Your entities are not exactly POCO > and are not exactly "persistence ignorant". > Apparently what you are trying to do is an implementation of ActiveRecord > patternhttp://martinfowler.com/eaaCatalog/activeRecord.html > > <http://martinfowler.com/eaaCatalog/activeRecord.html>Believe me that there > is no reason to use INHibernateProxy inside an entity nor inside a > DAO/Repository and in general in your app. > If you want study a good implementation of ActiveRecord pattern you can > study or use > Castle.ActiveRecordhttp://www.castleproject.org/activerecord/index.html > > If I well understand what you are trying to do is initialize a > proxy/property/collection. > To do it you dot't need anything else than > NHibernateUtil.Initialize(entity); > > 2009/9/23 Harm Neervens <[email protected]> > > > > > > > > > I want this because my entities are POCO, and bu that I mean real > > Persistance Ignorant. > > I have code in my entities that references ISessionFactory, I create a > > dependancy to the NHibernate framework, and that's not what I want. > > I'm building an abstraction layer between my domain model and the ORM. > > In that way we can change ORM framework whenever we want (just by > > adjusting some configuration settings). > > Some of our customers prefer NHibernate, other Entity Framework or > > NPersist. > > > When I always have proxies, then in my base class I can use code like: > > > if (entity is INHibernateProxy) > > { > > (entity as > > INHibernateProxy).HibernateLazyInitializer.Session.Load<T>..... etc > > } > > > and in case of NPersist: > > > if (entity is IInterceptable) > > { > > (entity as > > IInterceptable).Context.GetObjectById<T>....etc > > } > > > Harm. > > > Until now (I mean for almost 5 years) I used NPersist. This is an ORM > > developed by Mats Helander and Roger Alsing (www.puzzleframework.com). > > Because the development has stopped, and there's no active community, > > I started to look at NHibernate. Another reason is that more and more > > customers are asking for it. > > In Entity Framework 4, there will also be POCO support, so in the > > future my abstaction layer will also support EF. > > Maybe it's a bit clearer now to you why I always want proxies for my > > entities. > > > On Sep 23, 5:39 pm, José F. Romaniello <[email protected]> wrote: > > > > When I have no proxy, I cannot cast my object to IInterceptor and so I > > > > will never get to my session/context object within my entity. > > > > Well.. I have to much questions. Why do you need to do that? > > > Is not a good way to get the current session by far. > > > > Inject ISessionFactory and use GetCurrentSession().. is a normal > > approach. > > -- > Fabio Maulo- 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] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
