How do you mean?

On Wed, Aug 19, 2009 at 8:00 AM, Mikael Henriksson <[email protected]>wrote:

> Gaaah all these limitations everywhere :)
> Not that I care about the database it's just frustrating that I can't make
> it perfect!! Not saying it's your fault James, just saying that's all. I'll
> try to make it work in a different manner. What I was actually trying to
> accomplish was to not have to repeat myself too much. So this would be my
> next step. Can't I just use the same ClassMap for these guys?.
>
> On Tue, Aug 18, 2009 at 9:56 PM, James Gregory <[email protected]>wrote:
>
>> I assume what you're trying to do is have a Person table, and a
>> BoardMembers table, with BoardMember being a joined-subclass, and then any
>> derived BoardMember's being discriminated...?
>>
>> If that is the case, then I'm afraid you're out of
>> luck. Unless somebody knows otherwise, I'm pretty sure you can't do that 
>> with NHibernate. You'll need them to all be in the same table and call 
>> DiscriminateSubclassesOnColumn in your ClassMap.
>>
>> On Tue, Aug 18, 2009 at 8:42 PM, Mikael Henriksson 
>> <[email protected]>wrote:
>>
>>> I have many classes but only three is important for what I am trying to
>>> do.
>>> Let's say I have a person:
>>>     public class Person
>>>     {
>>>         public virtual int Id { get; private set; }
>>>         public virtual string FirstName { get; set; }
>>>         public virtual string LastName { get; set; }
>>>     }
>>>
>>> Now I want to inherit from person because a *board member *is a person.
>>> but I have different types of board members that I want to discriminate on
>>> for instance Chairman that inherits from BoardMember:
>>>     public class BoardMember : Person
>>>     {
>>>         public virtual Board Board { get; set; }
>>>         public virtual MemberTypes Type { get; set; }
>>>     }
>>>
>>>     public class Chairman : BoardMember
>>>     {
>>>
>>>     }
>>>
>>> Now I thought I would do something like:
>>> public class PersonMap : ClassMap<Person>
>>>  {
>>> public PersonMap()
>>> {
>>>  Table("person");
>>> Id(x => x.Id, "person_id");
>>> Map(x => x.FirstName, "person_first_name");
>>>  Map(x => x.LastName, "person_last_name");
>>> }
>>> }
>>>
>>>     public class BoardMemberMap : SubclassMap<BoardMember>
>>>     {
>>>         public BoardMemberMap()
>>>         {
>>>             Table("board_member");
>>>             Map(x => x.Type).Column("board_member_type");
>>>             DiscriminateSubclassOnColumn("board_member_type");
>>>         }
>>>     }
>>>
>>>      public class Chairman : SubclassMap<Chairman>
>>>     {
>>>         public Chairman()
>>>         {
>>>
>>>         }
>>>     }
>>>
>>> However DiscriminateSubclassOnColumn is not available within SubclassMap
>>> so how do I work around it? :)
>>>
>>>
>>>
>>
>>
>>
>
> >
>

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