protected override void DataPortal_Insert()
{
using (var ctx = ContextManager.GetManager(o.DAL.Database.DB, false))
{
int? newId = null;
ctx.DataContext.addThing(_name, _location, ref newId);
_id = System.Convert.ToInt32(newId);
FieldManager.UpdateChildren(this);
}
}
This is probably the most commonly asked question (one way or another) asked by newcomers to CSLA .NET.
Notice that Save() returns a value. In fact, it returns the saved object, which is different from the one you started with. So you must use that return value:
_customer = _customer.Save()
The reason for this is explained in the first couple chapters of Expert 2008 Business Objects.
Copyright (c) Marimer LLC