Behaviour Change for Overridden Base Class Properties

42 views
Skip to first unread message

Mr Bretticus

unread,
Aug 22, 2011, 11:02:46 PM8/22/11
to fluent-n...@googlegroups.com
Hi, I've recently upgraded from 1.0RTM to 1.2 and FNH has been throwing "Tried to add property 'X' when already added." I've traced this down to overriding properties in a child class as illustrated by the following test:

public abstract class Parent
{
public virtual string Name { get; set; }
}

public class Child : Parent
{
public override string Name { get; set; }
}

[TestClass]
public class When_inheriting_from_abstract_class
{
[TestMethod]
public void it_should_allow_property_override() {
var model = AutoMap.Source(new StubTypeSource(typeof(Parent), typeof(Child)));

var mappings = model.BuildMappings()
.First()
.Classes.First();

Assert.AreEqual("Name", mappings.Properties.First().Name);
}
}

Is this an expected behaviour change? I've not been able to find a reference to this change in the release notes for 1.1 or 1.2. If it is expected is there a workaround to enable the old behaviour (I don't want to IncludeBase)?

Cheers,
Brett

Mr Bretticus

unread,
Aug 26, 2011, 2:19:09 AM8/26/11
to Fluent NHibernate
Oops, the Parent was not meant to be included in the Source types.
Regardless the problem still exists.
Reply all
Reply to author
Forward
0 new messages