Arf! You are right :) I get too many updates every day, don't have time to
read them fully! Anyway, I did the following for now which seems to be
working fine but it's not that intuitive. The SubClassMap would be "neater"
for a n00b like me. It took me almost 10 minutes to figure out how to do the
subclass. I had to really dig into the source code for fluent to figure it
out.
public PersonMap()
{
WithTable("persons");
Id(x => x.Id, "person_id");
Map(x => x.FirstName, "person_first_name");
Map(x => x.LastName, "person_last_name");
Map(x => x.CreatedAt, "created_at");
JoinedSubClass<Contact>("person_id", MapContact);
}
private static void MapContact(JoinedSubClassPart<Contact> part)
{
part.WithTableName("contacts");
part.Map(x => x.Email, "contact_email");
part.Map(x => x.Phone, "contact_phone");
part.Map(x => x.Mobile, "contact_mobile");
part.Component(x => x.Address, c =>
{
c.Map(x => x.StreetOne,
"address_street_one");
c.Map(x => x.StreetTwo,
"address_street_two");
c.Map(x => x.Zip,
"address_zip");
c.Map(x => x.City,
"address_city");
c.Map(x => x.Country,
"address_country");
});
part.References(x => x.ContactType)
.LazyLoad()
.Cascade.All()
.ColumnName("contact_type_id");
}
2009/7/23 James Gregory <[email protected]>
> No, you don't. If it's twitter where you got your information from, you'll
> see that I also specified "on the model branch". Not trunk.
>
>
> On Thu, Jul 23, 2009 at 6:39 AM, Mikael Henriksson
> <[email protected]>wrote:
>
>> Don't know if I am retarded or not but I only find SubClass within
>> SubClassPart...is that what I am supposed to use for the parent? Now I get
>> it. The part.. this class is part of a series of classes that are joined.
>> Nice. Ok so I want JoinedSubclassPart<Parent> and then JoinedSubClass<Child>
>> hehe time to experiment
>>
>> 2009/7/23 James Gregory <[email protected]>
>>
>> Hopefully everything should be documented before we release 1.0. In the
>>> mean time, just ask here and I'll answer. SubclassMap just works the same as
>>> ClassMap really.
>>> public class ParentMap : ClassMap<Parent>
>>> {
>>> public ParentMap()
>>> {
>>> Id(x => x.Id);
>>>
>>> // regular mapping
>>> }
>>> }
>>>
>>> // child
>>> public class ChildMap : SubclassMap<Child>
>>> {
>>> public ChildMap()
>>> {
>>> // child mappings
>>> }
>>> }
>>>
>>> On Wed, Jul 22, 2009 at 10:57 PM, Mikael Henriksson <
>>> [email protected]> wrote:
>>>
>>>> And of course you just submit the changes I need.
>>>> Thanks James!
>>>>
>>>> When will you have time to document? SubClassMap needs a quickie on the
>>>> wiki :)
>>>>
>>>> 2009/7/22 James Gregory <[email protected]>
>>>>
>>>> JoinedSubclass is what you need.
>>>>>
>>>>> On Wed, Jul 22, 2009 at 10:46 PM, Mikael Henriksson <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I can't find any good information on this topic. The only examples I
>>>>>> can find is AutoMapping. What I have is two classes Person and
>>>>>> ContactPerson. I map them separately not using
>>>>>> DiscriminateSubClassOnColumn
>>>>>> or whatever it is called. I tried table-per-class-hierarchy but I don't
>>>>>> like
>>>>>> it. I want table-per-subclass but don't know how to do it fluently. Any
>>>>>> suggestions?
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---