Sure. I'll see if time can be found within a week or so. On Sat, Aug 28, 2010 at 7:08 PM, Fabio Maulo <[email protected]> wrote:
> It is possible but I'm not sure about how much it is good... > You are delegating a business responsibility to the persistence layer. > > Btw, if you want, you can implement this feature in your > own IPersistentCollection using the property Owner, then you can inject > the ICollectionTypeFactory and have it working for any collections. > After do that would be nice to share your solution in some public > repository as Sourceforge, CodePlex, GoogleCode, GitHub, BitBucket and so > on. > > > On Sat, Aug 28, 2010 at 12:22 PM, Jacob Madsen <[email protected]> wrote: > >> So you do not believe its possible to extend NHibernate with this >> responsibility? >> >> >> On Sat, Aug 28, 2010 at 5:08 PM, nadav s <[email protected]> wrote: >> >>> Read about mapping many-to-one >>> anyway, nhibernate will set the many to one property when you retrieve >>> elements from Db, but setting the many to one property when an element is >>> added to the entity is all up to you >>> >>> On Sat, Aug 28, 2010 at 5:58 PM, Jacob Madsen <[email protected]> wrote: >>> >>>> Hi there, >>>> >>>> I believe NHibernate might be able to help me set a "many-to-one >>>> relationship property", since it must have the necessary knownledge about >>>> the relationship. Maybe set it within an intercepter or listener? >>>> >>>> public class Entity >>>> { >>>> public int Id { get; set; } >>>> >>>> IList<Element> Elements { get; set; } >>>> >>>> public Entity() >>>> { >>>> Elements = new List<Element>(); >>>> } >>>> } >>>> >>>> public class Element >>>> { >>>> public int Id { get; set; } >>>> public Entity RelationshipProperty { get; set; } // NH might be >>>> able to set this property when its comitting? >>>> } >>>> >>>> using (var session = sessionFactory.OpenSession()) >>>> using (var tx = session.BeingTransaction()) >>>> { >>>> var entity = new Entity(); >>>> >>>> entity.Elements.Add(new Element()); // Instead >>>> of: entity.Elements.Add(new Element() { RelationshipProperty = entity >>>> }); >>>> >>>> session.Save(entity); >>>> >>>> tx.Commit(); >>>> } >>>> >>>> Cheers! >>>> >>>> -- >>>> 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]<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. >> > > > > -- > 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]<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.
