views:

521

answers:

1

I'm building ASP.Net MVC aplication based on UnitOfWorkApplication and I'd like to use Castle ATM facility. At the moment I've problem with flushing the session on request end. My service class (which is called in my controller action method) looks like this:

[Transactional]
public class UserAdminService : IUserAdminService
{

 [Transaction(TransactionMode.Requires)]
 public User CreateNewUser(string username, string password, string firstName, string lastName)
 {
  var u = new User(username)
           {
            PasswordHash = GetPasswordHash(password),
            FirstName = firstName,
            LastName = lastName
           };
  userRepo.Save(u);
  //UnitOfWork.CurrentSession.Flush();
  return u;
 }

When I uncomment the "UnitOfWork.CurrentSession.Flush();" row everything works fine - new user is persisted in DB. But nothing is persisted if I don't flush the session explicitely.

The UnitOfWorkApplication + ATM should flush changes on request end AFAIK - is that right? Does anybody have an advice what should I try to make it work without the explicit session.Flush() call?

+1  A: 

I just registered RhinoTransactionFacility instead of original Castle ATM facility + DefaultTransactionManager and everything started to work.

Buthrakaur