The idea with a map might work. Thanks!

And yes, we are selling a compiler/IDE/framework.

On Sep 12, 5:37 pm, nadav s <[email protected]> wrote:
> i'm not sure that it is the best way to do it, but if you map children to
> the parent with a Map (IDictionary<int,Child>)
> and have the following properties
>
> class Parent
> {
> protected virtual IDictionary<int,Child> Children {get;set;}
>
> public virtual Child First
> {
> get
> {
> return this.Children.ContainsKey(1) ?
> this.Children[1] :
> null;}
>
> set
> {
> this.Children[1] = value;
>
> }
> }
> }
>
> and the similar implementation for the Second child. if you have arbitrary
> properties (unlike "First", "Second")
> you can set the Children property to be IDictionary<string,Child>
>
> that said, i totally agree with diego, but if that is the requirement i
> think private dictionary and properties accessing it could work
>
> On Sun, Sep 12, 2010 at 11:17 PM, Diego Mijelshon 
> <[email protected]>wrote:
>
>
>
> > Supporting arbitrary models defined by the customer is a recipe for
> > disaster, unless you are selling a compiler, an IDE or a framework like
> > NHibernate.
> > Just sayin'.
>
> >     Diego
>
> > On Fri, Sep 10, 2010 at 12:10, v64 <[email protected]> wrote:
>
> >> I need the child to be parented through one of several properties on
> >> the same parent. A child still has a single parent, but the system
> >> needs to distinguish which property on the parent points to a
> >> particular child instance.
>
> >> Unfortunately I cannot give a real world domain example. We are
> >> building a dynamic model where the customer would be able to define
> >> the entities and their relationships and we dinamically generate the
> >> mapping (and the db schema) based on the customer model. The scenario
> >> that I described looks like a valid object model, and we need to
> >> support it. This is what it would look like in terms of classes:
>
> >> class Parent
> >> {
> >>    public Child first;
> >>    public Child second;
> >> }
>
> >> class Child
> >> {
> >>    public Parent parent;
> >> }
>
> >> Thanks,
> >> v64
>
> >> On Sep 9, 6:28 pm, José F. Romaniello <[email protected]> wrote:
> >> > by using a different key-column?
>
> >> > <class name="Parent">
> >> >    <set name="Children1" inverse="true" cascade="all-delete-orphan">
> >> >        <key column="parent_id_1"/>
> >> >        <one-to-many class="Child"/>
> >> >    </set>
> >> >    <set name="Children2" inverse="true" cascade="all-delete-orphan">
> >> >        <key column="parent_id_2"/>
> >> >        <one-to-many class="Child"/>
> >> >    </set>
> >> > </class>
>
> >> > <class name="Child">
> >> >    <many-to-one name="Parent1" column="parent_id_1" not-null="true"/>
> >> >    <many-to-one name="Parent2" column="parent_id_2" not-null="true"/>
> >> > </class>
>
> >> > Show a real world domain, where you need this.
>
> >> > 2010/9/9 v64 <[email protected]>
>
> >> > > Hi,
>
> >> > > My parent class has two collection properties that hold entities of
> >> > > the same type. I'm trying to understand the correct way to map this.
> >> > > Using the example from the docs:
>
> >> > > <class name="Parent">
> >> > >    <set name="Children1" inverse="true" cascade="all-delete-orphan">
> >> > >        <key column="parent_id"/>
> >> > >        <one-to-many class="Child"/>
> >> > >    </set>
> >> > >    <set name="Children2" inverse="true" cascade="all-delete-orphan">
> >> > >        <key column="parent_id"/>
> >> > >        <one-to-many class="Child"/>
> >> > >    </set>
> >> > > </class>
>
> >> > > <class name="Child">
> >> > >    <many-to-one name="Parent" column="parent_id" not-null="true"/>
> >> > > </class>
>
> >> > > This obviously will not work because there's no way to tell which
> >> > > parent collection a child belongs to. How do I map this?
>
> >> > > TIA
> >> > > v64
>
> >> > > --
> >> > > 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%252bunsubscr...@googlegroup­s.com>
> >> ­>
> >> > > .
> >> > > 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.
>
> >  --
> > 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.- 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.

Reply via email to