let's say i have the following entities:
public class Order
{
public int OrderID {get;set;};
public int Version {get;set;};
public IList<OrderDetail> Details {get;set;}
}
public class OrderDetail
{
public int OrderDetailID {get;set;}
/// Some other properties
}
when i want to delete the entity like this:
Order order = new Order { OrderID = 9, Version =1 };
ITransaction tr = Session.BeginTransaction();
Session.Delete(order);
tr.Commit();
well the order is deleted, but the details is still there with (OrderID) foreign key set to null ? but when i try to delete it like this, it worked as expected:
Order order = Session.Get<Order>(9);
ITransaction tr = Session.BeginTransaction();
Session.Delete(order);
tr.Commit();
why should i have to get the entire entity from database, in order to delete it?
BTW: i tried to create an instance of Order and fill the information and details information manually, it also worked???
can't i just do it as simple as possible ?