阅读背景:

流畅的NHibernate获取保存对象的Id

来源:互联网 

I'm using Fluent NHibernate in an Asp.net MVC application. I have it set up to start a session and transaction on every request, and commit the transaction at the request end. However, what I want to do is save an object (in this case, a new "Company") and then redirect to that new Company's detail page. How do I get the Id of the new company so that I can redirect? If I get the Id after session.Save(company), it is null. This makes sense as it hasn't yet been committed, however, it still seems there should be a relatively easy way to do this without committing the current transaction and starting a new one.I'm using Fluent NHibernate in an Asp.net MVC a




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: