Hi,
I have a working model:

namespace NHibernateMapping.Models.Entities
{
   public class TabMaster : INHibernateModel
   {
       public TabMaster()
       { }
       public TabMaster(string Configuration, string ResolutionType)
       {
           this.Id = new TabMasterCompositeKey(Configuration,
ResolutionType);
       }
       public virtual TabMasterCompositeKey Id { get; set; }
       public virtual string Configuration
       {
           get { return Id.Configuration; }
           set {
               if (Id == null) Id = new TabMasterCompositeKey();
               Id.Configuration = value;
           }
       }
       public virtual string ResolutionType
       {
           get { return Id.ResolutionType; }
           set {
               if (Id == null) Id = new TabMasterCompositeKey();
               Id.ResolutionType = value;
           }
       }
       public virtual string Description { get; set; }
       public virtual string Title { get; set; }
       public virtual string idResolutionFileDes { get; set; }
       public virtual string WorkflowType { get; set; }
       public virtual string ViewAllStep { get; set; }
       public virtual string ManagedData { get; set; }

       public override string ToString()
       {
           return Id.ToString();
       }
   }
}

namespace NHibernateMapping.Models.CompositeKeys
{
   public class TabMasterCompositeKey
   {
       public TabMasterCompositeKey()
       { }
       public TabMasterCompositeKey(string Configuration, string
ResolutionType)
       {
           this.Configuration = Configuration;
           this.ResolutionType = ResolutionType;
       }
       public virtual string Configuration { get; set; }
       public virtual string ResolutionType { get; set; }
       public override bool Equals(object obj)
       {
           TabMasterCompositeKey compareTo =
(TabMasterCompositeKey)obj;
           return (this.Configuration == compareTo.Configuration) &&
(this.ResolutionType == compareTo.ResolutionType);
       }
       public override int GetHashCode()
       {
           return this.ToString().GetHashCode();
       }
       public override string ToString()
       {
           return Configuration.ToString() + "/" +
ResolutionType.ToString();
       }
   }
}

that I can map with this Map:

namespace NHibernateMapping.Controllers.Mappings
{
   public class TabMasterMap : ClassMap<TabMaster>
   {
       public TabMasterMap()
       {
           CompositeId()
               .ComponentCompositeIdentifier<TabMasterCompositeKey>(x
=> x.Id)
               .KeyProperty(x => x.Id.Configuration)
               .KeyProperty(x => x.Id.ResolutionType);
           Map(x => x.Description);
           Map(x => x.Title);
           Map(x => x.idResolutionFileDes);
           Map(x => x.WorkflowType);
           Map(x => x.ViewAllStep);
           Map(x => x.ManagedData);
       }
   }
}

generating this hbm.xml file:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
 <class xmlns="urn:nhibernate-mapping-2.2" lazy="true"
name="NHibernateMapping.Models.Entities.TabMaster,
NHibernateMapping.Models, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" table="`TabMaster`">
   <composite-id name="Id"
class="NHibernateMapping.Models.CompositeKeys.TabMasterCompositeKey,
NHibernateMapping.Models, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null">
     <key-property name="Configuration" type="System.String,
mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089">
       <column name="Configuration" />
     </key-property>
     <key-property name="ResolutionType" type="System.String,
mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089">
       <column name="ResolutionType" />
     </key-property>
   </composite-id>
   <property name="Description" type="System.String, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <column name="Description" />
   </property>
   <property name="Title" type="System.String, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <column name="Title" />
   </property>
   <property name="idResolutionFileDes" type="System.String,
mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089">
     <column name="idResolutionFileDes" />
   </property>
   <property name="WorkflowType" type="System.String, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <column name="WorkflowType" />
   </property>
   <property name="ViewAllStep" type="System.String, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <column name="ViewAllStep" />
   </property>
   <property name="ManagedData" type="System.String, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <column name="ManagedData" />
   </property>
 </class>
</hibernate-mapping>

Now I want to get same using AutoMapping solution:

what can I do?

My main problem is to automatically get the compositeid.

Any suggestion?

Thanks.

Emanuele Fabbri

-- 
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