On Thu, Dec 31, 2015 at 2:41 PM, Michael Powell <mwpowell...@gmail.com> wrote:
> Hello,
>
> I have some confusion about how to best handle meta-ownership of
> parent/child records. Briefly, I have a statistics table whose rows
> may be owned by one of several parent tables.

I got past that bit, but now on the return trip, reading the values
back out of the database, I am getting messages about the parent's Id.
Somehow this is ignoring the Id conventions, or I want to verify that
the convention includes this as a use case, not quite certain as to
which (?).

I verified in the database, the child records are indeed saved, the
hosting model type full name is correctly represented, but the Id is
showing in an "unconventional" way, at least how I think I've got the
conventions mapped. But I could be wrong.

Exception messages:

SQL: SELECT cohorts0_.SlotId as SlotId1_, cohorts0_.Id as Id1_,
cohorts0_.Id as Id654_0_, cohorts0_.Type as Type654_0_,
cohorts0_.CreatedOn as CreatedOn654_0_, cohorts0_.HostModelType as
HostMode4_654_0_, cohorts0_.HostModelId as HostMode5_654_0_ FROM
StatisticalCohorts cohorts0_ WHERE
(System.Linq.Expressions.PropertyExpression = Football.Models.Slot)
and cohorts0_.SlotId=?

could not initialize a collection:
[Football.Models.Slot.Cohorts#cac80bb6-3c7b-4784-a99c-a57f00fd21ee][SQL:
SELECT cohorts0_.SlotId as SlotId1_, cohorts0_.Id as Id1_,
cohorts0_.Id as Id654_0_, cohorts0_.Type as Type654_0_,
cohorts0_.CreatedOn as CreatedOn654_0_, cohorts0_.HostModelType as
HostMode4_654_0_, cohorts0_.HostModelId as HostMode5_654_0_ FROM
StatisticalCohorts cohorts0_ WHERE
(System.Linq.Expressions.PropertyExpression = Football.Models.Slot)
and cohorts0_.SlotId=?]

The multi-part identifier "System.Linq.Expressions.PropertyExpression"
could not be bound.

> In order to do this, I am using Fluent's AddMetaValue from the
> AnyPart<T>, but I think I am confused about its usage.
>
> Somewhere along the way I thought this applied to typeof (TModel) with
> a valueMap of typeof (TClassMap) where TClassMap is ClassMap<T>.
>
> Initial assignment of the domain model is correct. I assign instance
> of Parent to Child class' HostModel property. Type shows typeof
> (Parent), all is well.
>
> However, when the object saves, the meta value shows ParentMap, which
> I do not think is correct, and hence part of my confusion.
>
> Here's an example of my extension method to handle this. I know what I
> was driving for, but I don't recall why I was assuming TClassMap?
> Except, perhaps as a way of enforcing that TClass should be mapped.
>
> public static AnyPart<T> AddMetaValue<T, TClass, TClassMap>(this
> AnyPart<T> part)
>     where TClassMap : ClassMap<TClass>
>     where TClass : T
> {
>     return part.AddMetaValue(typeof (TClass), typeof (TClassMap).Name);
> }
>
> I think probably that should read more like:
>
> return part.AddMetaValue(typeof (TClass), typeof (TClass).Name);
>
> Thoughts? Insights?
>
> Thank you,
>
> 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 https://groups.google.com/group/fluent-nhibernate.
For more options, visit https://groups.google.com/d/optout.

Reply via email to