Skip to content

Instantly share code, notes, and snippets.

@hconceicao
Created January 4, 2012 02:56
Show Gist options
  • Save hconceicao/1558240 to your computer and use it in GitHub Desktop.
Save hconceicao/1558240 to your computer and use it in GitHub Desktop.
using (ISession session = sessionManager.OpenSession())
{
transaction = session.Transaction;
Assert.IsFalse(transaction.IsActive);
FirstDao service = container.Resolve<FirstDao>("myfirstdao");
// This call is transactional
Blog blog = service.Create();
RootService rootService = container.Resolve<RootService>();
Array blogs = rootService.FindAll(typeof (Blog));
Assert.AreEqual(1, blogs.Length);
}
[Transaction]
public virtual Blog Create(String name)
{
using (ISession session = sessManager.OpenSession())
{
NUnit.Framework.Assert.IsTrue(session.Transaction.IsActive);
Blog blog = new Blog();
blog.Name = name;
session.Save(blog);
return blog;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment