For anyone interested, I think I've found the solution. The key was to use the Formula attribute on the discriminator.
Formula = CASE WHEN ItemTypeID IN (4, 5) THEN 4 ELSE ItemTypeID END Now data with ItemTypeID = 4 or ItemTypeID = 5 can be mapped into the class ItemD. Any issues with this approach? Ultimately the cause is that we are using a discriminator which doesn't neatly conform to class boundaries. Each class can map to multiple ItemTypeIDs. However, no ItemTypeID will span classes. On Feb 1, 9:27 am, mbag <gunnith...@gmail.com> wrote: > I agree that this approach would work, but I was hoping it wouldn't be > necessary. > > There's a very subtle different between ItemE and ItemD and so > segregating them via the ItemTypeID makes sense, but in terms of > properties, logic etc. they are functionally the same. > > Any other suggestions? > > On Jan 30, 3:38 am, cliff vaughn <cliftonfvau...@gmail.com> wrote: > > > create a 5th class: > > > public class ItemE : ItemD > > { > > > } > > > your example would suggest there's reason for it and probably some behavior > > that could be in this new class. > > > On Fri, Jan 29, 2010 at 11:24 PM, mbag <gunnith...@gmail.com> wrote: > > > I'm having trouble mapping the following setup in FNH. Any help would > > > be appreciated. > > > > /***** Classes for Item Hierarchy *****/ > > > > public class ItemA > > > { > > > public string AProperty { get; set; } > > > } > > > > public class ItemB : ItemA > > > { > > > public string BProperty { get; set; } > > > } > > > > public class ItemC : ItemB > > > { > > > public string CProperty { get; set; } > > > } > > > > public class ItemD : ItemB > > > { > > > public string DProperty { get; set; } > > > } > > > > /***** Tables for Item Hierarchy *****/ > > > > TABLE A (ItemID INT, ItemTypeID INT, AProperty VARCHAR(100)) > > > TABLE A (ItemID INT, ItemTypeID INT, BProperty VARCHAR(100)) > > > TABLE A (ItemID INT, ItemTypeID INT, CProperty VARCHAR(100)) > > > TABLE A (ItemID INT, ItemTypeID INT, DProperty VARCHAR(100)) > > > > /***** ItemTypeID to Class *****/ > > > > ItemTypeID = 1 --> ItemA > > > ItemTypeID = 2 --> ItemB > > > ItemTypeID = 3 --> ItemC > > > > ItemTypeID = 4 --> ItemD > > > ItemTypeID = 5 --> ItemD > > > > /***** ItemTypeID to Table *****/ > > > > ItemTypeID = 1 --> Data is in Table A > > > ItemTypeID = 2 --> Data is in Table A Join B > > > ItemTypeID = 3 --> Data is in Table A Join B Join C > > > > ItemTypeID = 4 --> Data is in Table A Join B Join D > > > ItemTypeID = 5 --> Data is in Table A Join B Join D > > > > I would like to use a Discriminator column (ItemTypeID) but the > > > SubClassMap<ItemD> would have to accept either a value of 4 or 5. Is > > > this possible? > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Fluent NHibernate" group. > > > To post to this group, send email to fluent-nhibern...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2bunsubscr...@googlegroups.com> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/fluent-nhibernate?hl=en. > > > -- > > thanks > > > cliff -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibern...@googlegroups.com. To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.