I've worked out a similar situation using interfaces like this:

interface IProfileA

class ProfileA : IProfileA

interface IProfileB

class ProfileB : IProfileB

interface IProfileProxy : IProfileA, IProfileB


then specifying proxy="Namespace.IProfileProxy" in the base class mapping
and working against the interfaces.


On Thu, Mar 19, 2009 at 2:02 PM, 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