请教各位高手NHibernate的事务问题?
如果我要同时插入多表,要做事务控制,既要么同时插入,要么都回滚,请问该怎么处理?,我怎么做都要不行呢 --------------------编程问答-------------------- --------------------编程问答-------------------- Nh里不是有个什么Session可以启用事务控制的么 --------------------编程问答--------------------ITransaction transaction = session.BeginTransaction();--------------------编程问答-------------------- Session 是 持续化 --------------------编程问答-------------------- ActiveRecord
try
{
session.Save(entity1);
session.Save(entity2);
session.Save(entity3);
transaction.Commit();
}
catch(Exception ex)
{
transaction.Rollback();
throw ex;
}
finally
{
session.Close();
}
using(new SessionScope())
{
Blog blog = new Blog();
blog.Author = "hammett";
blog.Name = "some name";
blog.Save();
Post post = new Post(blog, "title", "post contents", "Castle");
post.Save();
}
补充:.NET技术 , LINQ