Hi all, I am new to using nHibernate and have come across this issue when I try saving my object. This is a WEB project and apparently many of the solutions suggest to embed the XML file as a resource. Don't think I can do that with a web project... here is my code:
Code:
namespace Timesheet.BusinessObjects
{
/// <summary>
/// Creates an instance of Customer.
/// </summary>
public class Customer : PersistentManager
{
// Properties
public DateTime DateModified { get; private set; }
public String CustomerName { get; private set; }
public Int64 CustomerID { get; private set; }
public Int64 ProjectID { get; private set; }
// Constructor
public Customer()
{
}
// Methods
public static Customer CreateCustomer(string customerName)
{
Customer customer = new Customer();
customer.CustomerName = customerName;
customer.DateModified = DateTime.Now;
customer.ProjectID = 0;
customer.Save(); //Error here
return customer;
}
}
}
Here is my mapping file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Timesheet.BusinessObjects.Customer" table="Customers" lazy="false">
<id name="CustomerID">
<column name="CustomerID" />
<generator class="native" />
</id>
<property name="DateModified"></property>
<property name="CustomerName"></property>
<property name="CustomerID"></property>
<property name="ProjectID"></property>
</class>
</hibernate-mapping>
Thanks all in advance.