only question:

what's the convention by which the discriminator column value maps to a
given class? (parent or child1, child2, etc)

is it literally just the typename, -namespace? (what if i need to
discriminate by namespaces because there are types with the same names in
different NSes?)

*                               ID          TYPE                  *
EntityBase     ->    1      "EntityBase"
EntityChildA   ->     2      "EntityChildA"
EntityChildB   ->      3      "EntityChildB"

------
Joe Brockhaus
[email protected]
------------


On Thu, Jan 27, 2011 at 4:37 AM, James Gregory <[email protected]>wrote:

> You're not doing basic inheritance mapping.
>
> You can't have multiple discriminator columns. If that's what you're trying
> to do with your SubTypeType, then it isn't going to work. You have one
> discriminator column for the entire table.
>
> To map a table-per-hierarchy with Fluent NHibernate you do this:
>
> public class EntityBaseMap : ClassMap<EntityBase>
> {
>   public EntityBaseMap()
>   {
>     Id(x => x.Id);
>
>     DiscriminateSubclassesOnColumn("Type");
>   }
> }
>
> public class EntityChildAMap : SubclassMap<EntityChildA>
> {
> }
>
> public class EntityChildBMap : SubclassMap<EntityChildB>
> {
> }
>
> That will create a single table for all the subclasses. If you want them to
> have their own tables, remove the Discriminate method call.
>
> A subclass doesn't have a unique identifier, hence the lack of the Id
> method in SubclassMap, as it inherits that identifier from the class it
> extends. If you need to use a different column name for the primary key in
> the table, then you should use the KeyColumn method from inside your
> SubclassMap.
>
> --
> 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]<fluent-nhibernate%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/fluent-nhibernate?hl=en.
>

-- 
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.

Reply via email to