Hi Fabio, That is how I currently handle it in our dao's:
public TProxy Load<TEntity, TProxy>(object id) { return (TProxy) session.Load(typeof(TEntity), id); } Remco On Oct 12, 7:49 pm, Fabio Maulo <fabioma...@gmail.com> wrote: > It seems to be a feature request:session.Load<TMappedClass, TProxy>(object > id) > > 2009/10/12 Skafa <r....@rawsoft.nl> > > > > > > > And, ofcourse, you should do the casting yourself: > > > var skill = (ISkill) session.Load(typeof(Skill), id); > > > On 30 sep, 07:16, Richard Dingwall <rdingw...@gmail.com> wrote: > > > I have the following class and mapping: > > > > public interface ISkill : IObjectWithId<int> {...} > > > public class Skill : ISkill, ObjectWithId<int>, IEquatable<Skill> > > > {...} > > > > <class name="Skill" table="Skill"proxy="ISkill">...</class> > > > > Skill has a few collections but no subclasses. > > > > Fetching skills via Session.Get<T>() works great, but callingLoad() > > > always throws an internal NH exception: > > > > ISkill skill = Session.Load<Skill>(42); > > > > System.InvalidCastException : Unable to cast object of type > > > 'INHibernateProxyProxy' to type 'Abc.DomainModel.Xyz.Skill'. > > > at NHibernate.Impl.SessionImpl.Load[T](Object id) > > > > It's maybe (probably) something really dumb I am doing, but is this > > > not a massive flaw? > > > > Why bother having a generic version ofLoad() if it doesn't support > > > lazy loading, its primary use case? Could we get a more useful error > > > message at least? > > > > Using NH 2.1.0.GA. I tried with LinFu, Spring and Castle and all > > > implementations had the same result. > > > > The other alternative, specifying theproxydoesn't work either, > > > because it is aproxynot a mapped class and NH doesn't recognize > > > querying by proxies. > > > > ISkill skill = Session.Load<ISkill>(42); // cannot resolve unmapped > > > class 'ISkill' > > > > Someone please explain where I am going wrong here! > > > > Rich > > -- > Fabio Maulo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhusers@googlegroups.com To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---