Using an event listener is something I considered and implemented. However, The user is usually not loaded directly but rather as a member of several other objects. So using the event model yields the parent entity and then I have to provide logic to update the right properties depending on the type and the object graph. Including the service at the level of the type avoids that and it seemed cleaner to me. I just haven't found a way to provide a service to the type since it must have a null constructor. Using a service locator isn't a technique I've got experience with. Would that get around the constructor issue?
On Jun 13, 2012, at 11:36 AM, Ricardo Peres <[email protected]> wrote: > 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. > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/nhusers/-/E1k8WI0bHO4J. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
