Can anybody confirm that this does not work as expected, as I am getting an error that it is trying to access property rather then trying to access field.
private IList<MetaPackage> _metaPackages;
public virtual IEnumerable<MetaPackage> MetaPackages
{
get
{
return _metaPackages;
}
}
Fluent mapping
HasMany<MetaPackage>(x
=>x.MetaPackages).Table("dnnSphere_Package").KeyColumn("Id")
.Inverse().LazyLoad().Cascade.AllDeleteOrphan()
.Access.ReadOnlyPropertyThroughCamelCaseField(Prefix.Underscore)
Unit Test
new PersistenceSpecification<MetaProject>(Session)
.CheckProperty(x => x.Name, "Test")
.CheckProperty(x => x.Description, "Description")
.CheckList(x=>x.MetaPackages, new List<MetaPackage> { new
MetaPackage ("name")})
.VerifyTheMappings();
Error:
It throws an error that it cannot find Property setter, even though it should go trough a field, as it is readonly property.
System.ArgumentException: Property set method not found. at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index) at FluentNHibernate.Testing.PersistenceSpecification
1.ListValue
1.SetValue(Ob ject target) in E:\Users\epitka\Documents\DEVELOPMENT\fluent- nhibernate\src\FluentNHibernate\Testing\PersistenceSpecification.cs: line 174
If if switch strategy to use ReadOnlyPropertyTrhoughPascalCaseField it correctly throws this error:
NHibernate.PropertyNotFoundException: Could not find field '_MetaPackages' in class 'dnnSphere.Meta.Model.MetaProject'
So it seems that ReadOnlyPropertyThroughCamelCaseField(Prefix.Underscore) is mapping it incorrectly to property rather then to a field.