You are right. IIRC, in my case I've used other information (from my model) to know which type to use.
Perhaps this method cannot be used in every scenario. On Fri, Apr 3, 2009 at 11:03 AM, domonkos <[email protected]> wrote: > > In this case both (User.Profile is IProfileA) and (User.Profile is > IProfileB) always be true. > And he still can't decide whether the User.Profile is instance of > ProfileA or ProfileB, am I right? > > On Mar 21, 2:07 pm, Germán Schuager <[email protected]> wrote: > > Specifying IProfileProxy you can cast any lazy-loaded Profile to either > > IProfileA or IProfileB and then work against the interface. > > Is that what you were asking for? > > > > On Fri, Mar 20, 2009 at 9:39 PM, kello <[email protected]> wrote: > > > > > I don't see how an interface that derives from two other interfaces > > > would help in doing different things depending on the type? For > > > example > > > > > if (Profile is ProfileA) DoA(); else if(Profile is ProfileB) DoB(); > > > > > Or when using the Visitor pattern.... Am I missing something? > > > > > /Jonas > > > > > On Mar 20, 10:35 pm, Germán Schuager <[email protected]> wrote: > > > > 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.- > Hide > > > quoted text - > > > > > > - Show quoted text - > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
