I'm working on my first NHibernate project, so this may seem to be a simple question.
The below is simplified from my real scenario to convey the specific question.
Lets say I have a Customer entity
public class Customer
{
prop virtual int ID { get; set; }
prop virtual string Name { get; set; }
prop virtual Region Region { get; set; }
}
and my Region Entity (regions are like, NorthWest, MidWest, etc - a pretty defined list that would be in some sort of drop-down)
public class Region
{
prop virtual int ID { get; set; }
prop virtual string Name { get; set; }
private readonly IList<Customer> _customers = new List<Customer>();
public virtual void Add(Customer customer)
{
_customers.Add(customer);
}
public virtual void Remove(Customer customer)
{
_customers.Remove(customer);
}
public virtual Customer[] GetCustomers()
{
return _customers.ToArray();
}
}
When I go to Persist a Customer Entity, I really only want to have 3 pieces of information (Customer.ID, Customer.Name, & Customer.Region.ID), how do I accomplish this, because NHibernate expects a Customer entity that includes a full Region entity (not just the ID)...