Why can't you cast it because of the proxy? If the proxy would
actually be derived from ProfileA, you should be able to cast it to
ProfileA. Are you sure that you don't actually have a proxy of
Profile? Check your mapping, did you define the subclasses and
discriminators correctly? What is the type you are storing?

If you turn off lazy loading, you'll see if there is still a problem.

On 19 Mrz., 18:02, RoyWagner <[email protected]> wrote:
> This is the situation:
>
> I have an abstract Profile class and 2 derived classes let’s call the
> ProfileA and ProfileB.
> Then mapping structure that I use is table per class hierarchy.
>
> I also  have a user class that have reference to a Profile:
>
> Public class User
> {
>         public virtual Profile Profile { get; set; }
>
> }
>
> I use lazy load for the Profile property.
>
> The problem is that when try to cast the User.Profile to one of the
> derived classes(PofileA or ProfileB) I get an error that I can’t cast
> ProfileProxy16982… to ProfileA.
> NHibernate create ProfileProxy object in order to support the lazy
> load and that prevent me from casting the Profile object.
>
> The only solution I have right now is to cancel the lazy load.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to