I don't think there is, but if the argument is not a proxy, Unproxy returns it unmodified, so you don't need to check it manually. You can still use "if (proxy is INHibernateProxy)" if you want.
In any case, if you find yourself doing this often, you should rethink about your design. Most apps shouldn't have to worry about proxies (frameworks might). In my case, I only needed to do it once to retrieve an instance of the correct type when using inheritance and lazy loading. Diego On Tue, Mar 9, 2010 at 16:07, Graham Bunce <[email protected]> wrote: > To extend this slightly, is there an NHibernate IsProxy method? > > I've looked at the NHibernateProxyHelper but nothing in there. The > above almost gave me what I needed but in some edge cases I may have > an initialised proxy that will pass an NHibernateUtil.IsInitialized > check but still not cast to a concrete type. > > I've simulated an IsProxy (I think) by comparing a current type to the > NHibernateProxyHelper.GetClassWithoutInitializingProxy method : > > entity.GetType() != > NHibernateProxyHelper.GetClassWithoutInitializingProxy(entity); > > but I'm a little concerned that it may fail with some edge cases to > with subclasses etc. Basically, all I need to know know is "Is the > current entity a proxy", regardless of whether its initalised or not. > I can then use the code Diego gave me to sort out what I need to > afterwards. > > Thanks > > -- > 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]<nhusers%[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.
