Umbraco .NET 用户控件 - 流畅的 NHibernate
有人对将 Fluent NHibernate(或者任何 ORM)插入 Umbraco 访问的 .NET 用户控件有什么建议吗?我无法弄清楚创建 NHibernate 会话的起点在哪里。
例如,在 ASP.NET MVC 项目中,我可以使用 Global.asax 中的 Applicatoin_Start 和 Application_BeginRequest 事件来创建存储库并将其注入到我的控制器中。在我正在处理的这个 Umbraco 项目中,我将调用一个用户控件(即:Search.ascx),并直接在 Umbraco 内部引用该控件。当然,我也会有它的 dll。但是有没有一种方法可以创建 NHibernate 会话,而不必每次发出请求时都完全设置它?
这个博客文章看起来很有趣,但它从未继续到第 2 部分。
如果有任何示例项目/教程可以引导我完成此操作,请告诉我。
Does anyone have any suggestions for plugging Fluent NHibernate (or really any ORM) into a .NET user control accessed by Umbraco? I'm having trouble figuring out where the starting point is for creating the NHibernate session.
For example, on an ASP.NET MVC project, I can use the Applicatoin_Start and Application_BeginRequest events in the Global.asax to create a repository and inject it into my controller. On this Umbraco project I'm working on, I'm just going to be calling a user control (ie: Search.ascx), and referencing that control directly inside of Umbraco. Sure, I'll have the dll for it as well. But is there a way to create an NHibernate session without having to completely set it up each time I make a request?
This blog post looked interesting, however it never continued on to a part 2.
Please let me know if there are any sample project/tutorials that can walk me through this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是一个 umbraco 特定问题,就像您有一个用户控件一样,它更像是一个 ASP.Net 问题。
我认为推荐的方法是每个请求都有一个会话,请参阅:
http: //ryanlanciaux.com/ryanlanciaux/post/NHibernate-Session-Per-Request.aspx
我希望这会有所帮助。
This isn't an umbraco specific question as if you have a user control it is more an ASP.Net question.
I think the recommended appraoch to to have a session per request, see:
http://ryanlanciaux.com/ryanlanciaux/post/NHibernate-Session-Per-Request.aspx
I hope this helps.