You *have* to map the Id, but you are not required to have a property for it.
<class name="HelloWorldNHibernate.Customer" table="Customers" lazy="false" dynamic-insert="true"> *<id column="id_col_name" type="id_col_type">* * <generator class="identity"/>* * </id>* <property name="FirstName" /> <property name="LastName" /> </class> Diego On Thu, Nov 19, 2009 at 05:53, code_blocker <[email protected]> wrote: > hi, > > Say I have an object relational mapping. The database table has an > identity column but I don't want to include this information in my > object. How would I implement this? > > The code (which I thought should work but doesn't) for the class > Customer and its mapping file are below: > > class Customer > { > # region Decalarations > private String p_FirstName = String.Empty; > private String p_LastName = String.Empty; > #endregion > > #region Constructor > public Customer() { } > > public Customer(String FirstName, String LastName) > { > p_FirstName = FirstName; > p_LastName = LastName; > } > #endregion > > # region Properties > public virtual String FirstName > { > get { return p_FirstName; } > set { p_FirstName = value; } > } > > public virtual String LastName > { > get { return p_LastName; } > set { p_LastName = value; } > } > # endregion > } > > > > > > > > > <?xml version="1.0"?> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > namespace="HelloWorldNHibernate" > assembly="HelloWorldNHibernate"> > > <!-- Mappings for class 'Customer' --> > <class name="HelloWorldNHibernate.Customer" > table="Customers" > lazy="false" > dynamic-insert="true"> > > <property name="FirstName" /> > <property name="LastName" /> > > </class> > > </hibernate-mapping> > > -- > > 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=. > > > -- 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=.
