> maaping and the code would be perfect

Here you are :)

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MyAssembly"
namespace="MyAssembly">
  <class name="MyAssembly.Customer,MyAssembly" table="`Customer`">
    <id name="CustomerId" column="CustomerId"  type="Int32"
unsaved-value="0">
      <generator class="native"></generator>
    </id>
    <property name="LastName" column="`LastName`" type="string" length="50"
not-null="true"></property>
    <property name="FirstName" column="`FirstName`" type="string"
length="50" not-null="false"></property>
    <property name="Email" column="`Email`" type="string" length="50"
not-null="false"></property>
    <property name="Code" column="`Code`" type="string" unique="true"
length="50" not-null="true"></property>

    <!-- Customer / Order -->
    <set name="Orders" table="`Order`" generic="true" inverse="true">
      <key column="`CustomerId`"/>
      <one-to-many class="MyAssembly.Order,MyAssembly"/>
    </set>
  </class>
</hibernate-mapping>

//When I load in the IList
using (var session = GetSessionFactory().OpenSession())
using (var tx = session.BeginTransaction())
{
    try
    {
        List = Session.CreateCriteria(typeof(T))
            .List<T>();
        BindingSource.DataSource = List;
        tx.Commit();
    }
    catch (NHibernate.HibernateException ex)
    {
        tx.Rollback();
        MessageException = ex.Message;
        throw ex;
    }
}

//Save
using (var session = GetSessionFactory().OpenSession())
using (var tx = session.BeginTransaction())
{
    try
    {
        CustomerManager customerManager = new CustomerManager(session);
        foreach (Customer item in List)
            Session.SaveOrUpdate(item);
        tx.Commit();
    }
    catch (NHibernate.HibernateException ex)
    {
        tx.Rollback();
        MessageException = ex.Message;
        throw ex;
    }
}

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