I am using ISession.SaveOrUpdate to insert new objects and updaet existing.
If I use ISession.Save(..) this returns the identity of the inserted record.
For SaveOrUpdate I am doing the following:
public int Save(Vehicle entity) {
using (var txn = _session.BeginTransaction()) {
_session.SaveOrUpdate(entity);
txn.Commit();
}
return entity.Id;
}
Is this the best way to return my identity?
Thanks,
Ben