Well, the question kinda nails it down. I'm currently doing something like this:
using (var session = _sessionFactory.OpenSession())
{
using (var transaction = ses开发者_如何学编程sion.BeginTransaction())
{
Car newCar = new Car();
newCar.name = "Jeep";
session.Save(newCar);
transaction.Commit();
}
}
return newCar.Id;
After you've committed your transaction of course.
精彩评论