From 1155c656c8121d4eec18b9207705dac009add1ef Mon Sep 17 00:00:00 2001 From: Alex Zaytsev Date: Thu, 30 May 2024 14:02:38 +1000 Subject: [PATCH 1/5] Remove unnecessary type lookup --- .../XmlHbmBinding/ClassCompositeIdBinder.cs | 4 +- .../Cfg/XmlHbmBinding/ClassIdBinder.cs | 4 +- .../Cfg/XmlHbmBinding/PropertiesBinder.cs | 67 ++++++++++++------- src/NHibernate/Mapping/Any.cs | 6 ++ src/NHibernate/Mapping/Collection.cs | 2 + src/NHibernate/Mapping/Component.cs | 6 ++ src/NHibernate/Mapping/IValue.cs | 3 + src/NHibernate/Mapping/OneToMany.cs | 2 + src/NHibernate/Mapping/SimpleValue.cs | 21 ++++++ src/NHibernate/Mapping/ToOne.cs | 11 +++ 10 files changed, 99 insertions(+), 27 deletions(-) diff --git a/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs b/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs index 00e384c5e76..99ea0ad6b3c 100644 --- a/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs +++ b/src/NHibernate/Cfg/XmlHbmBinding/ClassCompositeIdBinder.cs @@ -190,7 +190,7 @@ private Property CreateProperty(ToOne value, string propertyName, System.Type pa { if (parentClass != null && value.IsSimpleValue) { - value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName, + value.SetTypeUsingReflection(parentClass, propertyName, keyManyToOneSchema.access ?? mappings.DefaultAccess); } @@ -242,7 +242,7 @@ private Property CreateProperty(SimpleValue value, string propertyName, System.T { if (parentClass != null && value.IsSimpleValue) { - value.SetTypeUsingReflection(parentClass.AssemblyQualifiedName, propertyName, + value.SetTypeUsingReflection(parentClass, propertyName, keyPropertySchema.access ?? mappings.DefaultAccess); } diff --git a/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs b/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs index e0a1c4ad245..23618a368fc 100644 --- a/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs +++ b/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs @@ -45,7 +45,7 @@ private void CreateIdentifierProperty(HbmId idSchema, PersistentClass rootClass, if (idSchema.name != null) { string access = idSchema.access ?? mappings.DefaultAccess; - id.SetTypeUsingReflection(rootClass.MappedClass == null ? null : rootClass.MappedClass.AssemblyQualifiedName, idSchema.name, access); + id.SetTypeUsingReflection(rootClass.MappedClass, idSchema.name, access); var property = new Property(id) { Name = idSchema.name }; @@ -85,4 +85,4 @@ private static void BindUnsavedValue(HbmId idSchema, SimpleValue id) id.NullValue = idSchema.unsavedvalue ?? (id.IdentifierGeneratorStrategy == "assigned" ? "undefined" : null); } } -} \ No newline at end of file +} diff --git a/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs b/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs index 3fbbc63aa57..826632632de 100644 --- a/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs +++ b/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs @@ -103,7 +103,7 @@ public void Bind(IEnumerable properties, Table table, ID { var value = new SimpleValue(table); new ValuePropertyBinder(value, Mappings).BindSimpleValue(propertyMapping, propertyName, true); - property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); + property = CreateProperty(entityPropertyMapping, mappedClass, value, inheritedMetas); BindValueProperty(propertyMapping, property); } else if ((collectionMapping = entityPropertyMapping as ICollectionPropertiesMapping) != null) @@ -124,14 +124,14 @@ public void Bind(IEnumerable properties, Table table, ID var subpath = propertyName == null ? null : StringHelper.Qualify(propertyBasePath, propertyName); var value = CreateNewComponent(table); BindComponent(propertiesMapping, value, null, entityName, subpath, componetDefaultNullable, inheritedMetas); - property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); + property = CreateProperty(entityPropertyMapping, mappedClass, value, inheritedMetas); BindComponentProperty(propertiesMapping, property, value); } else if ((manyToOneMapping = entityPropertyMapping as HbmManyToOne) != null) { var value = new ManyToOne(table); BindManyToOne(manyToOneMapping, value, propertyName, true); - property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); + property = CreateProperty(entityPropertyMapping, mappedClass, value, inheritedMetas); BindManyToOneProperty(manyToOneMapping, property); } else if ((componentMapping = entityPropertyMapping as HbmComponent) != null) @@ -141,14 +141,14 @@ public void Bind(IEnumerable properties, Table table, ID // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute System.Type reflectedClass = mappedClass == null ? null : GetPropertyType(componentMapping.Class, mappedClass, propertyName, componentMapping.Access); BindComponent(componentMapping, value, reflectedClass, entityName, subpath, componetDefaultNullable, inheritedMetas); - property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); + property = CreateProperty(entityPropertyMapping, mappedClass, value, inheritedMetas); BindComponentProperty(componentMapping, property, value); } else if ((oneToOneMapping = entityPropertyMapping as HbmOneToOne) != null) { var value = new OneToOne(table, persistentClass); BindOneToOne(oneToOneMapping, value); - property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); + property = CreateProperty(entityPropertyMapping, mappedClass, value, inheritedMetas); BindOneToOneProperty(oneToOneMapping, property); } else if ((dynamicComponentMapping = entityPropertyMapping as HbmDynamicComponent) != null) @@ -158,14 +158,14 @@ public void Bind(IEnumerable properties, Table table, ID // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute System.Type reflectedClass = mappedClass == null ? null : GetPropertyType(dynamicComponentMapping.Class, mappedClass, propertyName, dynamicComponentMapping.Access); BindComponent(dynamicComponentMapping, value, reflectedClass, entityName, subpath, componetDefaultNullable, inheritedMetas); - property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); + property = CreateProperty(entityPropertyMapping, mappedClass, value, inheritedMetas); BindComponentProperty(dynamicComponentMapping, property, value); } else if ((anyMapping = entityPropertyMapping as HbmAny) != null) { var value = new Any(table); BindAny(anyMapping, value, true); - property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); + property = CreateProperty(entityPropertyMapping, mappedClass, value, inheritedMetas); BindAnyProperty(anyMapping, property); } else if ((nestedCompositeElementMapping = entityPropertyMapping as HbmNestedCompositeElement) != null) @@ -179,19 +179,19 @@ public void Bind(IEnumerable properties, Table table, ID // NH: Modified from H2.1 to allow specifying the type explicitly using class attribute System.Type reflectedClass = mappedClass == null ? null : GetPropertyType(nestedCompositeElementMapping.Class, mappedClass, propertyName, nestedCompositeElementMapping.access); BindComponent(nestedCompositeElementMapping, value, reflectedClass, entityName, subpath, componetDefaultNullable, inheritedMetas); - property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); + property = CreateProperty(entityPropertyMapping, mappedClass, value, inheritedMetas); } else if ((keyPropertyMapping = entityPropertyMapping as HbmKeyProperty) != null) { var value = new SimpleValue(table); new ValuePropertyBinder(value, Mappings).BindSimpleValue(keyPropertyMapping, propertyName, componetDefaultNullable); - property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); + property = CreateProperty(entityPropertyMapping, mappedClass, value, inheritedMetas); } else if ((keyManyToOneMapping = entityPropertyMapping as HbmKeyManyToOne) != null) { var value = new ManyToOne(table); BindKeyManyToOne(keyManyToOneMapping, value, propertyName, componetDefaultNullable); - property = CreateProperty(entityPropertyMapping, className, value, inheritedMetas); + property = CreateProperty(entityPropertyMapping, mappedClass, value, inheritedMetas); } if (property != null) @@ -402,31 +402,52 @@ private void BindCollectionProperty(ICollectionPropertiesMapping collectionMappi property.Cascade = collectionMapping.Cascade ?? mappings.DefaultCascade; } - private Property CreateProperty(IEntityPropertyMapping propertyMapping, string propertyOwnerClassName, IValue value, IDictionary inheritedMetas) + private Property CreateProperty(IEntityPropertyMapping propertyMapping, System.Type propertyOwnerType, SimpleValue value, IDictionary inheritedMetas) { if (string.IsNullOrEmpty(propertyMapping.Name)) { - throw new MappingException("A property mapping must define the name attribute [" + propertyOwnerClassName + "]"); + throw new MappingException("A property mapping must define the name attribute [" + propertyOwnerType + "]"); } var propertyAccessorName = GetPropertyAccessorName(propertyMapping.Access); - if (!string.IsNullOrEmpty(propertyOwnerClassName) && value.IsSimpleValue) - value.SetTypeUsingReflection(propertyOwnerClassName, propertyMapping.Name, propertyAccessorName); + if (propertyOwnerType != null && value.IsSimpleValue) + value.SetTypeUsingReflection(propertyOwnerType, propertyMapping.Name, propertyAccessorName); var property = new Property - { - Name = propertyMapping.Name, - PropertyAccessorName = propertyAccessorName, - Value = value, - IsLazy = propertyMapping.IsLazyProperty, - LazyGroup = propertyMapping.GetLazyGroup(), - IsOptimisticLocked = propertyMapping.OptimisticLock, - MetaAttributes = GetMetas(propertyMapping, inheritedMetas) - }; + { + Name = propertyMapping.Name, + PropertyAccessorName = propertyAccessorName, + Value = value, + IsLazy = propertyMapping.IsLazyProperty, + LazyGroup = propertyMapping.GetLazyGroup(), + IsOptimisticLocked = propertyMapping.OptimisticLock, + MetaAttributes = GetMetas(propertyMapping, inheritedMetas) + }; return property; } + + private Property CreateProperty(IEntityPropertyMapping propertyMapping, string propertyOwnerClassName, Mapping.Collection value, IDictionary inheritedMetas) + { + if (string.IsNullOrEmpty(propertyMapping.Name)) + { + throw new MappingException("A property mapping must define the name attribute [" + propertyOwnerClassName + "]"); + } + + var propertyAccessorName = GetPropertyAccessorName(propertyMapping.Access); + + return new Property + { + Name = propertyMapping.Name, + PropertyAccessorName = propertyAccessorName, + Value = value, + IsLazy = propertyMapping.IsLazyProperty, + LazyGroup = propertyMapping.GetLazyGroup(), + IsOptimisticLocked = propertyMapping.OptimisticLock, + MetaAttributes = GetMetas(propertyMapping, inheritedMetas) + }; + } private string GetPropertyAccessorName(string propertyMappedAccessor) { diff --git a/src/NHibernate/Mapping/Any.cs b/src/NHibernate/Mapping/Any.cs index 3be627b9d6b..8fd6d421ad9 100644 --- a/src/NHibernate/Mapping/Any.cs +++ b/src/NHibernate/Mapping/Any.cs @@ -72,10 +72,16 @@ public void ResetCachedType() _type = GetLazyType(); } + // Since v5.6 + [Obsolete("This method is not used and will be removed in a future version")] public override void SetTypeUsingReflection(string className, string propertyName, string access) { } + public override void SetTypeUsingReflection(System.Type propertyOwnerType, string propertyName, string access) + { + } + /// /// Get or set the metatype /// diff --git a/src/NHibernate/Mapping/Collection.cs b/src/NHibernate/Mapping/Collection.cs index 5ebcd301ebc..769e29e814c 100644 --- a/src/NHibernate/Mapping/Collection.cs +++ b/src/NHibernate/Mapping/Collection.cs @@ -593,6 +593,8 @@ public virtual bool IsAlternateUniqueKey get { return false; } } + // Since v5.6 + [Obsolete("This method is not used and will be removed in a future version")] public void SetTypeUsingReflection(string className, string propertyName, string access) { } diff --git a/src/NHibernate/Mapping/Component.cs b/src/NHibernate/Mapping/Component.cs index c9f1409cf6f..99a395e6686 100644 --- a/src/NHibernate/Mapping/Component.cs +++ b/src/NHibernate/Mapping/Component.cs @@ -105,10 +105,16 @@ public Component(Component component) owner = component.Owner; } + // Since v5.6 + [Obsolete("This method is not used and will be removed in a future version")] public override void SetTypeUsingReflection(string className, string propertyName, string accesorName) { } + public override void SetTypeUsingReflection(System.Type propertyOwnerType, string propertyName, string accesorName) + { + } + /// public bool IsEmbedded { diff --git a/src/NHibernate/Mapping/IValue.cs b/src/NHibernate/Mapping/IValue.cs index 1941b3dc563..9bfb3522b01 100644 --- a/src/NHibernate/Mapping/IValue.cs +++ b/src/NHibernate/Mapping/IValue.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using NHibernate.Engine; using NHibernate.Type; @@ -78,6 +79,8 @@ public interface IValue FetchMode FetchMode { get; } + // Since v5.6 + [Obsolete("This method is not used and will be removed in a future version")] void SetTypeUsingReflection(string className, string propertyName, string accesorName); object Accept(IValueVisitor visitor); diff --git a/src/NHibernate/Mapping/OneToMany.cs b/src/NHibernate/Mapping/OneToMany.cs index b349e4df98b..35a82f60a43 100644 --- a/src/NHibernate/Mapping/OneToMany.cs +++ b/src/NHibernate/Mapping/OneToMany.cs @@ -125,6 +125,8 @@ public bool IsAlternateUniqueKey get { return false; } } + // Since v5.6 + [Obsolete("This method is not used and will be removed in a future version")] public void SetTypeUsingReflection(string className, string propertyName, string accesorName) { } diff --git a/src/NHibernate/Mapping/SimpleValue.cs b/src/NHibernate/Mapping/SimpleValue.cs index 29de8c8927b..7714f120fd4 100644 --- a/src/NHibernate/Mapping/SimpleValue.cs +++ b/src/NHibernate/Mapping/SimpleValue.cs @@ -341,6 +341,8 @@ public bool IsAlternateUniqueKey set { isAlternateUniqueKey = value; } } + // Since v5.6 + [Obsolete("This method is not used and will be removed in a future version")] public virtual void SetTypeUsingReflection(string className, string propertyName, string accesorName) { if (typeName == null) @@ -359,6 +361,25 @@ public virtual void SetTypeUsingReflection(string className, string propertyName } } } + + public virtual void SetTypeUsingReflection(System.Type propertyOwnerType, string propertyName, string accessorName) + { + if (typeName == null) + { + if (propertyOwnerType == null) + { + throw new MappingException("you must specify types for a dynamic entity: " + propertyName); + } + try + { + typeName = ReflectHelper.ReflectedPropertyClass(propertyOwnerType, propertyName, accessorName).AssemblyQualifiedName; + } + catch (HibernateException he) + { + throw new MappingException("Problem trying to set property type by reflection", he); + } + } + } public virtual object Accept(IValueVisitor visitor) { diff --git a/src/NHibernate/Mapping/ToOne.cs b/src/NHibernate/Mapping/ToOne.cs index c959216d4b4..a56245f32da 100644 --- a/src/NHibernate/Mapping/ToOne.cs +++ b/src/NHibernate/Mapping/ToOne.cs @@ -54,6 +54,8 @@ public bool IsLazy /// public abstract override void CreateForeignKey(); + // Since v5.6 + [Obsolete("This method is not used and will be removed in a future version")] public override void SetTypeUsingReflection(string className, string propertyName, string accesorName) { if (referencedEntityName == null) @@ -63,6 +65,15 @@ public override void SetTypeUsingReflection(string className, string propertyNam } } + public override void SetTypeUsingReflection(System.Type propertyOwnerType, string propertyName, string accessorName) + { + if (referencedEntityName == null) + { + System.Type refType = ReflectHelper.ReflectedPropertyClass(propertyOwnerType, propertyName, accessorName); + referencedEntityName = refType.FullName; + } + } + public override bool IsValid(Engine.IMapping mapping) { if (referencedEntityName == null) From 4cbac19e780d6027435b512f2a2fd4e42a60b181 Mon Sep 17 00:00:00 2001 From: Alex Zaytsev Date: Thu, 30 May 2024 14:08:53 +1000 Subject: [PATCH 2/5] Obsolete some methods --- src/NHibernate/Util/ReflectHelper.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/NHibernate/Util/ReflectHelper.cs b/src/NHibernate/Util/ReflectHelper.cs index e665a68a9c3..b693956de95 100644 --- a/src/NHibernate/Util/ReflectHelper.cs +++ b/src/NHibernate/Util/ReflectHelper.cs @@ -391,6 +391,8 @@ public static IGetter GetGetter(System.Type theClass, string propertyName, strin /// /// The NHibernate for the named property. /// + // Since v5.6 + [Obsolete("This method is not used and will be removed in a future version")] public static IType ReflectedPropertyType(System.Type theClass, string name, string access) { System.Type propertyClass = ReflectedPropertyClass(theClass, name, access); @@ -419,6 +421,8 @@ public static System.Type ReflectedPropertyClass(System.Type theClass, string na /// The name of the property/field to find in the class. /// The name of the property accessor for the property. /// The for the named property. + // Since v5.6 + [Obsolete("This method is not used and will be removed in a future version")] public static System.Type ReflectedPropertyClass(string className, string name, string accessorName) { try From 3af894af1afa7d0d0ace4f40d3261894e8955b59 Mon Sep 17 00:00:00 2001 From: Alex Zaytsev Date: Thu, 30 May 2024 15:05:48 +1000 Subject: [PATCH 3/5] Use type instead of class name --- src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs b/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs index 826632632de..539023a8768 100644 --- a/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs +++ b/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs @@ -4,7 +4,6 @@ using NHibernate.Mapping; using System; using NHibernate.Util; -using Array = System.Array; namespace NHibernate.Cfg.XmlHbmBinding { @@ -14,7 +13,6 @@ public class PropertiesBinder : ClassBinder private readonly Component component; private readonly string entityName; private readonly System.Type mappedClass; - private readonly string className; private readonly bool componetDefaultNullable; private readonly string propertyBasePath; @@ -38,7 +36,6 @@ public PropertiesBinder(Mappings mappings, PersistentClass persistentClass) this.persistentClass = persistentClass; entityName = persistentClass.EntityName; propertyBasePath = entityName; - className = persistentClass.ClassName; mappedClass = persistentClass.MappedClass; componetDefaultNullable = true; component = null; @@ -50,7 +47,6 @@ public PropertiesBinder(Mappings mappings, Component component, string className persistentClass = component.Owner; this.component = component; entityName = className; - this.className = component.ComponentClassName; mappedClass = component.ComponentClass; propertyBasePath = path; componetDefaultNullable = isNullable; @@ -116,7 +112,7 @@ public void Bind(IEnumerable properties, Table table, ID mappings.AddCollection(collection); - property = CreateProperty(collectionMapping, className, collection, inheritedMetas); + property = CreateProperty(collectionMapping, mappedClass, collection, inheritedMetas); BindCollectionProperty(collectionMapping, property); } else if ((propertiesMapping = entityPropertyMapping as HbmProperties) != null) @@ -428,11 +424,11 @@ private Property CreateProperty(IEntityPropertyMapping propertyMapping, System.T return property; } - private Property CreateProperty(IEntityPropertyMapping propertyMapping, string propertyOwnerClassName, Mapping.Collection value, IDictionary inheritedMetas) + private Property CreateProperty(IEntityPropertyMapping propertyMapping, System.Type propertyOwnerType, Mapping.Collection value, IDictionary inheritedMetas) { if (string.IsNullOrEmpty(propertyMapping.Name)) { - throw new MappingException("A property mapping must define the name attribute [" + propertyOwnerClassName + "]"); + throw new MappingException("A property mapping must define the name attribute [" + propertyOwnerType + "]"); } var propertyAccessorName = GetPropertyAccessorName(propertyMapping.Access); From 02fbe34ccc5e277ca96b958def79a405eb6f5b2b Mon Sep 17 00:00:00 2001 From: Alex Zaytsev Date: Thu, 30 May 2024 15:13:07 +1000 Subject: [PATCH 4/5] Code format --- src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs b/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs index 539023a8768..3188a1abfca 100644 --- a/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs +++ b/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs @@ -401,16 +401,14 @@ private void BindCollectionProperty(ICollectionPropertiesMapping collectionMappi private Property CreateProperty(IEntityPropertyMapping propertyMapping, System.Type propertyOwnerType, SimpleValue value, IDictionary inheritedMetas) { if (string.IsNullOrEmpty(propertyMapping.Name)) - { throw new MappingException("A property mapping must define the name attribute [" + propertyOwnerType + "]"); - } var propertyAccessorName = GetPropertyAccessorName(propertyMapping.Access); if (propertyOwnerType != null && value.IsSimpleValue) value.SetTypeUsingReflection(propertyOwnerType, propertyMapping.Name, propertyAccessorName); - var property = new Property + return new Property { Name = propertyMapping.Name, PropertyAccessorName = propertyAccessorName, @@ -420,16 +418,12 @@ private Property CreateProperty(IEntityPropertyMapping propertyMapping, System.T IsOptimisticLocked = propertyMapping.OptimisticLock, MetaAttributes = GetMetas(propertyMapping, inheritedMetas) }; - - return property; } private Property CreateProperty(IEntityPropertyMapping propertyMapping, System.Type propertyOwnerType, Mapping.Collection value, IDictionary inheritedMetas) { if (string.IsNullOrEmpty(propertyMapping.Name)) - { throw new MappingException("A property mapping must define the name attribute [" + propertyOwnerType + "]"); - } var propertyAccessorName = GetPropertyAccessorName(propertyMapping.Access); From c4cc1eff9efbfa09af229314cbd036731d27cbdc Mon Sep 17 00:00:00 2001 From: Alex Zaytsev Date: Sun, 9 Jun 2024 12:09:51 +1000 Subject: [PATCH 5/5] Resolve merge conflicts --- src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs b/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs index ecbae38121b..27106d57ea2 100644 --- a/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs +++ b/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs @@ -390,12 +390,12 @@ private Property CreateProperty(IEntityPropertyMapping propertyMapping, System.T { var type = propertyOwnerType?.UnwrapIfNullable(); if (string.IsNullOrEmpty(propertyMapping.Name)) - throw new MappingException("A property mapping must define the name attribute [" + propertyOwnerType + "]"); + throw new MappingException("A property mapping must define the name attribute [" + type + "]"); var propertyAccessorName = GetPropertyAccessorName(propertyMapping.Access); - if (propertyOwnerType != null && value.IsSimpleValue) - value.SetTypeUsingReflection(propertyOwnerType, propertyMapping.Name, propertyAccessorName); + if (type != null) + value.SetTypeUsingReflection(type, propertyMapping.Name, propertyAccessorName); return new Property {