This article might offer you some help: http://mookid.dk/oncode/archives/991
The proxy is a subclass of the base entity, so you can't just cast it to the inner class. However, you can break through the proxy layer by having a method on the object, which simply returns "this". Use at your own risk. On Oct 4, 5:16 am, Keith Nicholas <[email protected]> wrote: > I have :- > > public abstract class Item > { > public virtual int Id { get; set; } > } > > public class GeneralItem : Item > { > public virtual string Description { get; set; } > } > > public class LegacyItem: Item > { > public virtual string Name { get; set; } > } > > public class Blah > { > public virtual Item Item { get; set; } > } > > This is done as Table per subclass inheritance, now when I load an > object of type Blah, Item is a Item Proxy, and there seems to be no > way to recover the original Item ( either a legacy or general one ) > > I'm not sure if its a mapping problem? > > its mapped like > > public class ItemMap : ClassMap<Entities.Item> > { > public ItemMap() > { > Table("Items"); > Id(x => x.Id); > } > } > > public class GeneralItemMap : SubclassMap<Entities.GeneralItem> > { > public GeneralItemMap() > { > Table("GeneralItems"); > Map(x => x.Description); > } > } > > public class LegacyItemMap : SubclassMap<Entities.LegacyItem> > { > public LegacyItemMap() > { > Table("LegacyItems"); Map(x => x.Name); > } > } > > public class BlahMap : ClassMap<Entities.Blah> > { > public BlahMap() > { > Table("Blahs"); > Id(x => x.Id); > References(x => x.Item); > } > } > > I'd like some piece of code to be able to go something like :- > > var item = Repository.Items.Get(1); > > var legacy = item as LegacyItem; > > How can I achieve this? -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" 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/fluent-nhibernate?hl=en.
