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].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to