Why does it do this check in PropertyReference in the OneToOneMapper:

if (this._member != null && propertyInTheOtherSide.DeclaringType != this
._member.GetPropertyOrFieldType())
            {
                throw new ArgumentOutOfRangeException(
"propertyInTheOtherSide", string.Format("Expected a member of {0} found the 
member {1} of {2}", this._member.GetPropertyOrFieldType
(), propertyInTheOtherSide, propertyInTheOtherSide.DeclaringType));
            }

I have classes like so:

public class Owner {
    public Foo1 Foo1 {get;set;}
    public Foo2 Foo2 {get;set;}
}

public class Foo {
    public Owner Owner {get;set;}
}

public class Foo1 : Foo {
}

public class Foo2 : Foo {
}

I then have a mapping for Owner with a OneToOne like so:

OneToOne(x => x.Foo1, m =>
            {
                m.Cascade(Cascade.All);
                m.PropertyReference<Foo1>(x => x.Owner);
            });

This throws the exception, the only way I could get it to work is add an 
override for Owner to Foo1 and Foo2 like so and ignore the Owner property 
in the Foo1 and Foo2 mappings:

public class Foo1 {
    public Owner Owner {
        get { return base.Owner; }
        set { base.Owner = value; }
    }
}


Is there a better way to get around this *hack*?


Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/2XDEpp4Wbe8J.
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/nhusers?hl=en.

Reply via email to