private Property CreateProperty(IEntityPropertyMapping propertyMapping, string propertyOwnerClassName, IValue value, IDictionary <string, MetaAttribute> inheritedMetas) { if (string.IsNullOrEmpty(propertyMapping.Name)) { throw new MappingException("A property mapping must define the name attribute [" + propertyOwnerClassName + "]"); } var propertyAccessorName = GetPropertyAccessorName(propertyMapping.Access); if (!string.IsNullOrEmpty(propertyOwnerClassName) && value.IsSimpleValue) { value.SetTypeUsingReflection(propertyOwnerClassName, propertyMapping.Name, propertyAccessorName); } var property = new Property { Name = propertyMapping.Name, PropertyAccessorName = propertyAccessorName, Value = value, IsLazy = propertyMapping.IsLazyProperty, IsOptimisticLocked = propertyMapping.OptimisticLock, MetaAttributes = GetMetas(propertyMapping, inheritedMetas) }; return(property); }
// 6.0 TODO: Move to IEntityPropertyMapping as a property public static string GetLazyGroup(this IEntityPropertyMapping mapping) { if (mapping is HbmProperty property) { return(property.lazygroup); } if (mapping is HbmComponent component) { return(component.lazygroup); } return(null); }
public void WhenInterfaceIsImplementedByEntitiesThenRecognizeHeterogeneousAssociation() { var orm = new ObjectRelationalMapper(); orm.TablePerClass <MyEntity>(); orm.TablePerClass <MyRelation>(); orm.TablePerClass <MyOtherEntity>(); var mapper = new Mapper(orm); HbmMapping mapping = mapper.CompileMappingFor(new[] { typeof(MyEntity), typeof(MyRelation), typeof(MyDeepRelation), typeof(MyOtherEntity), typeof(MyOtherDeepRelation) }); HbmClass rc = mapping.RootClasses.First(r => r.Name.Contains("MyEntity")); IEntityPropertyMapping propertyRelation = rc.Properties.Where(p => p.Name == "Relation").Single(); propertyRelation.Should().Be.InstanceOf <HbmAny>(); IEntityPropertyMapping propertyDeepRelation = rc.Properties.Where(p => p.Name == "DeepRelation").Single(); propertyDeepRelation.Should().Be.InstanceOf <HbmAny>(); }
public void WhenInterfaceIsImplementedByEntitiesThenDoesNotRecognizeAsManyToOne() { // when there are more then one Hierarchy tree then it can't be directly interpreted as ManyToOne var orm = new ObjectRelationalMapper(); orm.TablePerClass <MyEntity>(); orm.TablePerClass <MyRelation>(); orm.TablePerClass <MyOtherEntity>(); var mapper = new Mapper(orm); HbmMapping mapping = mapper.CompileMappingFor(new[] { typeof(MyEntity), typeof(MyRelation), typeof(MyDeepRelation), typeof(MyOtherEntity), typeof(MyOtherDeepRelation) }); HbmClass rc = mapping.RootClasses.First(r => r.Name.Contains("MyEntity")); IEntityPropertyMapping propertyRelation = rc.Properties.Where(p => p.Name == "Relation").Single(); propertyRelation.Should().Not.Be.InstanceOf <HbmManyToOne>(); IEntityPropertyMapping propertyDeepRelation = rc.Properties.Where(p => p.Name == "DeepRelation").Single(); propertyDeepRelation.Should().Not.Be.InstanceOf <HbmManyToOne>(); }
private Property CreateProperty(IEntityPropertyMapping propertyMapping, string propertyOwnerClassName, IValue value, IDictionary<string, MetaAttribute> inheritedMetas) { if (string.IsNullOrEmpty(propertyMapping.Name)) { throw new MappingException("A property mapping must define the name attribute [" + propertyOwnerClassName + "]"); } var propertyAccessorName = GetPropertyAccessorName(propertyMapping.Access); if (!string.IsNullOrEmpty(propertyOwnerClassName) && value.IsSimpleValue) value.SetTypeUsingReflection(propertyOwnerClassName, propertyMapping.Name, propertyAccessorName); var property = new Property { Name = propertyMapping.Name, PropertyAccessorName = propertyAccessorName, Value = value, IsLazy = propertyMapping.IsLazyProperty, IsOptimisticLocked = propertyMapping.OptimisticLock, MetaAttributes = GetMetas(propertyMapping, inheritedMetas) }; return property; }