Isn't it an option to fully initialize all lazy fields when unproxying
the object? I do understand that this could have significant side
effects, but not being able to use NHibernate.Validator or the Linq
provider also look like significant side effects.

On Sep 21, 6:02 pm, Ayende Rahien <[email protected]> wrote:
> That is pretty much the point.
> There isn't an unproxy stage for an entity with lazy fields.
>
> To give you an example: User.Image is lazy
>
> var user = session.Load<User>(1); // user is a proxy
> NHibernateUtil.Initialize(user); // select id,name from user where id = 1
> var unproxiedUser = ((INHibernateProxy)user).GetImplementation();
>
> unproxiedUser is also proxy, because it need to intercept the get_Image call
>
> On Tue, Sep 21, 2010 at 5:43 PM, Allan Ritchie <[email protected]>wrote:
>
>
>
> > The problem is more widespread then just the LINQ provider.  You can't
> > unproxy the entity even at later stages outside of the LINQ provider.
>
> > On Sep 21, 9:18 am, pvginkel <[email protected]> wrote:
> > > I would be very surprised if this really would be a bug, because this
> > > would make the Linq provider unusable when enabling lazy properties.
> > > Feedback is very welcome.
>
> > > On Sep 21, 2:36 pm, Allan Ritchie <[email protected]> wrote:
>
> > > > I filed this as a bug.  It was claimed not to be a bug which is fine,
> > > > but contrib packages like nhibernate validator seem to fail against
> > > > lazy property proxies because of this exact issue.  Can anyone say
> > > > what the workaround is for this situation?
>
> > > > On Sep 20, 7:33 am, pvginkel <[email protected]> wrote:
>
> > > > > I have a Linq query which takes an entity as parameter. This entity
> > > > > itself is a proxy loaded with another Linq query and has lazy
> > > > > properties. In "ReflectHelper.cs(267): Assembly assembly =
> > > > > Assembly.Load(name.Assembly);" I get an FileNotFoundException because
> > > > > it tries to load the assembly of the proxy class. It looks like the
> > > > > problem is that
> > NHibernateProxyHelper.GetClassWithoutInitializingProxy
> > > > > can't determine the type of the entity because the proxy does not
> > > > > implement INHibernateProxy, so it returns the type of the proxy.
>
> > > > > Is this something I can solve in my configuration, or is something
> > > > > else going on here?
>
> > > > > I am using a nightly build of the NH3 trunk.

Reply via email to