You could use StructureMap to register your service and Common Service Locator, so that you don't have a dependency on StructureMap, inside the IUserType to retrieve your object.
But probably it would be better to have an event listener, for pre-load event, for example, and in there set a public property on your IUserType.
Just my 5 cents...
RP
On Wednesday, June 13, 2012 3:55:20 PM UTC+1, Matt Mueller wrote:
Hi, everyone. I'm a new member to the list and I'm hoping you can help me understand a problem that has plagued me for days. In my ASP MVC application I have a User type that is not persisted to the database but that I instead want to retrieve from Active Directory. I have a service for this purpose and I have an IUserType defined for the User entity that represents it as just an Id in the database but that returns a complete User object. The only thing I cannot figure out is how to supply my UserService to the IUserType. The process I see recommended most is to use a custom ByteCodeProvider with NHibernate. But some sources seem to indicate that these are not supported after version 3.2. I can't find any good documentation so could someone explain to me how to supply a service or other parameter to an IUserType. Ideally I would like it to be supply via StructureMap as it handles dependencies in the rest of my app. This is my first time around with NHibernate so any help or clarification you can give is greatly appreciated.