Best practice to join nhibernate and ASP.NET membership/role/profile services

不问归期 提交于 2019-12-20 12:25:01

问题


I've got a generic ASP.NET (MVC) application, that uses NHibernate as the model persistence layer, and ASP.NET Membership/role/profile services as the user management layer.

The question is what can be considered as the best practice to create linkings between the domain data and the users. (For example is I want to create a forum system I want to link each topics/posts to a specific user, and want to display the user at each request).

These are the posiibilites I've been thinking of:

  1. Store the user ID in NHibernate (like having a Guid column in all your domain classes (Posts, Topics etc.) that needs to reference a User) and use GetUser each time you need the name of the user from the guid (which might result in n+1 queries)

    B variant: Alternatively store the user name too.

  2. Use the same database, and create a read-only NHibernate maintaned domain object User, that maps to the same data as the M/R/P services do.
  3. Forget about M/R/P and create a separate user management service based on NHibernate
  4. Forget about both and use J2EE/RoR/merb/DJango/etc. (please don't pick this option :) )
  5. other...

回答1:


I would go for step 2 (almost, as it does not necessarily needs to be readonly) and create a custom membership provider for NHibernate.

To save time you can use an existing one like the one from Manuel Abadia.

With that you keep the full power of NHibernate (lazy loading, etc.) and enjoy M/R/P services too.




回答2:


There is also a NHibernate based Membership provider at CodePlex




回答3:


4 guys from rolla have an excellent post if you want to buil your own provider on top of the asp.net membership API : http://www.4guysfromrolla.com/articles/110310-1.aspx



来源:https://stackoverflow.com/questions/1000204/best-practice-to-join-nhibernate-and-asp-net-membership-role-profile-services

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!