Rhino 工作单元应用程序 + Castle 自动事务管理应用程序不会在请求结束时自动刷新
我正在基于 UnitOfWorkApplication 构建 ASP.Net MVC 应用程序,并且我想使用 Castle ATM 设施。 目前,我在请求结束时刷新会话时遇到问题。 我的服务类(在我的控制器操作方法中调用)如下所示:
[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;
}
当我取消注释“UnitOfWork.CurrentSession.Flush();”时 行一切正常 - 新用户保留在数据库中。 但是,如果我不明确刷新会话,则任何内容都不会保留。
UnitOfWorkApplication + ATM 应该在请求端刷新更改 AFAIK - 是这样吗? 有人建议我应该在没有显式 session.Flush() 调用的情况下尝试使其工作吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚注册了 RhinoTransactionFacility,而不是原来的 Castle ATM 设施 + DefaultTransactionManager,一切都开始工作了。
I just registered RhinoTransactionFacility instead of original Castle ATM facility + DefaultTransactionManager and everything started to work.