:((((
please clarify this for me, im aware that im probably doing something
wrong, but following the docs doesnt seem to work, neither does trial
and error :(
with or without this:
.Setup(s => s.SubclassStrategy = t => SubclassStrategy.JoinedSubclass)
if my base is abstract (which i want), i get xml mappings for each of
my subclasses will the properties from the base table on it. this is
wrong and obviously doesnt work with my db
If i make my base class non-abstract, i get a single baseclass.xml,
with the joined mappings in it (which is correct)
however, the <key><column name="DiaryEntry_Id" is wrong (should be
"id" from the base class), adding/removing the below makes no
difference:
public class DiaryEntryOverride : IAutoMappingOverride<DiaryEntry>
{
public void Override(AutoMapping<DiaryEntry> mapping)
{
mapping.JoinedSubClass<ActivityDiaryEntry>("id", m => { });
mapping.JoinedSubClass<FoodDiaryEntry>("id", m => { });
}
}
Making an override for one of the derived classes (to use ignore
property as per your recommendation yesterday) the ignoreproperty
doesnt work, the property still gets mapped.
public class ActivityDiaryEntryOverride :
IAutoMappingOverride<ActivityDiaryEntry>
{
public void Override(AutoMapping<ActivityDiaryEntry> mapping)
{
// this doesnt help, its ignored
mapping.Id(m => m.Id, "Id");
mapping.References(ade => ade._activity, "Activity_Id");
// This doesnt work
mapping.IgnoreProperty(x => x.Activity);
}
}
Am i being a noob?
Thanks
Andrew
On Aug 25, 10:33 am, James Gregory <
jagregory....@gmail.com> wrote:
> Abstract should have no bearing on your mappings. The issue with line 174 is
> because you're not supplying a lambda to the JoinedSubClass method (and
> we're not checking for nulls), pass it an empty lambda and it should work.
> mapping.JoinedSubClass<ActiveDiaryEntry>("id", m => {});
>
> As for the docs, IsBaseType was replaced in favor of IgnoreBase, I hadn't
> updated that part of the content to reflect that. If you want your whole
> class hierarchy mapped as subclasses then you really don't need to do
> anything, that's what that section is saying.
>
> Why is the abstract section confusing? There is no implications for using
> abstract base classes, they work fine.
>
> On Tue, Aug 25, 2009 at 10:26 AM,
trull...@googlemail.com <
>
>
>
>
trull...@googlemail.com> wrote:
>
> > This was originally a post about JoinedSubClass not working, but i've
> > since figured out how to get it working however the docs seem
> > contradictory
>
> > in 0.1 i had 3 classes, an abstract base and 2 derived. In the
> > database there is a table for each entity.
>
> > my mapping code for the joinedsubclassness was this:
>
> > public class DiaryEntryOverride : IAutoMappingOverride<DiaryEntry>
> > {
> > public void Override(AutoMapping<DiaryEntry> mapping)
> > {
> > mapping.JoinedSubClass<ActivityDiaryEntry>("id");
> > mapping.JoinedSubClass<FoodDiaryEntry>("id");
> > }
> > }
>
> > In 1.0RC however, I couldn't get this configuration to work. Turns out
> > i needed to make the base class non abstract, set this in the mapping
> > config and remove the above overrides:
>
> > .Setup(s => s.SubclassStrategy = t => SubclassStrategy.JoinedSubclass)
>
> > If i make the base class non-abstract, and keep the above override
> > code, FNH throwns a null reference at:
>
> > AutoMapping.cs Line: 174
>
> > the docs athttp://
wiki.fluentnhibernate.org/Auto_mapping#Inheritance