Created
January 4, 2012 02:56
-
-
Save hconceicao/1558240 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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