On Wed, Jul 8, 2015 at 6:22 PM, Michael Powell <mwpowell...@gmail.com> wrote:
> On Wed, Jul 8, 2015 at 5:27 PM, Michael Powell <mwpowell...@gmail.com> wrote:
>> Hello,
>>
>> With a couple of exceptions, I am mapping my classes as TPC (table per 
>> class).
>>
>> I now want to document some statistics throughout the model, but I
>> don't want to repeat myself where the stats tables are concerned.
>>
>> Let's say there was a base domain model called DomainModel (original,
>> I know...).
>>
>> My stat class should look something like the following:
>>
>> class Statistic
>> {
>>     public virtual DomainModel HostModel { get; set; }
>> }
>>
>> With DomainModel being something like this; although, in reality,
>> Statistics is probably in a DomainModel-derived base class:
>>
>> public virtual class DomainModel
>> {
>>     public virtual IList<Statistic> Statistics { get; set; }
>> }
>>
>> Excepting for the fact that I've mapped in the TPC, pattern, I'm not
>> sure how to discriminate DomainModel for the appropriate concrete
>> class(es).
>>
>> I really don't want to chase another mapping strategy at this stage of
>> the game, so I wonder what I can do to get past this.
>
> So far I've come up with something like this. Notice the Where clause,
> where HostModel "is" PlayerBase, in which PlayerBaseMap.
>
>             // Defer cascading to database triggers.
>             HasMany(x => x.Cohorts)
>                 .LazyLoad()
>                 .Inverse()
>                 .AsBag()
>                 .Where(x => x.HostModel is PlayerBase)
>                 .Cascade.None();
>
> The difficulty is, how to tell HostModel what to be saving?

Then from the perspective of the Cohort map:

            ReferencesAny(x => x.HostModel)
                .EntityTypeColumn(x => x.ModelType, CohortPrefix)
                .EntityIdentifierColumn(x => x.ModelId, CohortPrefix)
                .Cascade.None();

Thanks to a couple of property-accessing extension methods I cooked
up. Basically prefix-prepending wrappers to the string column name
ones "out of the box".

Haven't tested it yet...

>> I bright idea may occur to me once I send this, but in the meantime...
>> Any ideas?
>
> I'll experiment some more, but any insights are welcome and appreciated.
>
> Thank you...
>
>> Thank you...
>>
>> Best regards,
>>
>> Michael Powell

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fluent-nhibernate+unsubscr...@googlegroups.com.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
Visit this group at http://groups.google.com/group/fluent-nhibernate.
For more options, visit https://groups.google.com/d/optout.

Reply via email to