Another matter:
The class Team has two collections of Match
public IEnumerable<Match> MatchesAtHome
{
get{return matchesAtHome;}
}

public IEnumerable<Match> MatchesOnRoad
{
get{return matchesOnRoad;}
}
the relation is a bidirectional-one-to-many and you have to do something to
disambiguate the relation.
In practice I have to add some others lines of mapping.

On Tue, Nov 9, 2010 at 10:11 AM, Fabio Maulo <[email protected]> wrote:

> Ah... if you need some special behavior for cascade in many-to-one
> relations, or you have some one-to-one or many-to-many let us know.
>
>
> On Tue, Nov 9, 2010 at 10:07 AM, Fabio Maulo <[email protected]> wrote:
>
>> With the information you sent here your full mappings is:
>> private void ConfOrmMapping(ObjectRelationalMapper orm, Mapper mapper)
>>  {
>>  mapper.Customize<Match>(pc =>
>>                         {
>>                          pc.ManyToOne(match=> match.HomeRoster, mto=>
>> mto.Access(Accessor.Field));
>>  pc.ManyToOne(match => match.HomeTeam, mto =>
>> mto.Access(Accessor.Field));
>> pc.ManyToOne(match => match.RoadRoster, mto =>
>> mto.Access(Accessor.Field));
>>  pc.ManyToOne(match => match.RoadTeam, mto =>
>> mto.Access(Accessor.Field));
>> });
>>  }
>>
>> Expressed in XML it mean:
>>  <class name="Team" lazy="false">
>>     <id name="Id" type="Int32">
>>       <generator class="hilo">
>>         <param name="max_lo">100</param>
>>       </generator>
>>     </id>
>>     <set name="Rosters" access="field.camelcase" inverse="true"
>> cascade="all,delete-orphan">
>>       <key column="TeamId" />
>>       <one-to-many class="TeamRoster" />
>>     </set>
>>     <set name="Strategies" access="field.camelcase">
>>       <key column="TeamId" />
>>       <one-to-many class="Strategy" />
>>     </set>
>>     <set name="MatchesAtHome" access="field.camelcase" inverse="true"
>> cascade="all,delete-orphan">
>>       <key column="HomeTeamId" on-delete="cascade" />
>>       <one-to-many class="Match" />
>>     </set>
>>     <set name="MatchesOnRoad" access="field.camelcase" inverse="true"
>> cascade="all,delete-orphan">
>>       <key column="HomeTeamId" on-delete="cascade" />
>>       <one-to-many class="Match" />
>>     </set>
>>     <property name="Visible" />
>>     <property name="Name" />
>>     <property name="Location" />
>>   </class>
>>   <class name="Strategy">
>>     <id name="Id" type="Int32">
>>       <generator class="hilo">
>>         <param name="max_lo">100</param>
>>       </generator>
>>     </id>
>>   </class>
>>   <class name="Match" lazy="false">
>>     <id name="Id" type="Int32">
>>       <generator class="hilo">
>>         <param name="max_lo">100</param>
>>       </generator>
>>     </id>
>>     <many-to-one name="HomeTeam" access="field.camelcase"
>> column="HomeTeamId" />
>>     <many-to-one name="RoadTeam" access="field.camelcase"
>> column="RoadTeamId" />
>>     <many-to-one name="HomeRoster" access="field.camelcase"
>> column="HomeRosterId" />
>>     <many-to-one name="RoadRoster" access="field.camelcase"
>> column="RoadRosterId" />
>>   </class>
>>   <class name="Roster" lazy="false">
>>     <id name="Id" type="Int32">
>>       <generator class="hilo">
>>         <param name="max_lo">100</param>
>>       </generator>
>>     </id>
>>     <many-to-one name="Team" column="TeamId" />
>>     <set name="Players" access="field.camelcase">
>>       <key column="RosterId" />
>>       <one-to-many class="PlayerInTeam" />
>>     </set>
>>   </class>
>>   <class name="PlayerInTeam">
>>     <id name="Id" type="Int32">
>>       <generator class="hilo">
>>         <param name="max_lo">100</param>
>>       </generator>
>>     </id>
>>   </class>
>>   <joined-subclass name="TeamRoster" extends="Roster" lazy="false">
>>     <key column="Id" on-delete="cascade" />
>>     <property name="IsDefault" />
>>     <property name="Name" />
>>   </joined-subclass>
>>
>> Notes:
>> - the POID strategy 'increment' is not to use in production
>> - your classes are not proxyable and for that reason you can see the
>> lazy="false"
>> - you have some logic in the properties set; in those cases would be
>> better the access to field
>>
>> Have a nice day
>> --
>> Fabio Maulo
>>
>>
>
>
> --
> Fabio Maulo
>
>


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

Reply via email to