public override void MapField(ICustomizersHolder customizerHolder, IModelExplicitDeclarationsHolder modelExplicitDeclarationsHolder, PropertyPath currentPropertyPath, MetaEntity entity, MetaField property) { var m2mProperty = property as ManyToManyMetaField; var refEntity = _entityManager.GetEntity(m2mProperty.RefEntityName); var refProperty = refEntity.Fields[m2mProperty.MappedByFieldName]; var joinTableThisSideFkColumn = _nameConvention.EntityFieldToColumn(entity.Name.Split('.').Last() + "Id"); var joinTableOtherSideFkColumn = _nameConvention.EntityFieldToColumn(refEntity.Name.Split('.').Last() + "Id"); var bagMappingAction = new Action <IBagPropertiesMapper>(mapper => { mapper.Table(m2mProperty.JoinTable); mapper.Key(keyMapper => { keyMapper.Column(joinTableThisSideFkColumn); keyMapper.NotNullable(true); }); }); var m2mMappingAction = new Action <IManyToManyMapper>(mapper => { mapper.Class(refEntity.ClrType); mapper.Column(joinTableOtherSideFkColumn); }); var next = new PropertyPath(currentPropertyPath, property.ClrPropertyInfo); customizerHolder.AddCustomizer(next, m2mMappingAction); customizerHolder.AddCustomizer(next, bagMappingAction); modelExplicitDeclarationsHolder.AddAsManyToManyItemRelation(property.ClrPropertyInfo); modelExplicitDeclarationsHolder.AddAsBag(property.ClrPropertyInfo); }
public override void MapField(ICustomizersHolder customizerHolder, IModelExplicitDeclarationsHolder modelExplicitDeclarationsHolder, PropertyPath currentPropertyPath, MetaEntity entity, MetaField property) { var o2mProperty = property as OneToManyMetaField; var refEntity = _entityManager.GetEntity(o2mProperty.RefEntityName); var refProperty = refEntity.Fields[o2mProperty.MappedByFieldName]; var bagMappingAction = new Action <IBagPropertiesMapper>(mapper => { mapper.Inverse(true); mapper.Key(keyMapper => { keyMapper.Column(property.DbName); }); }); var o2mMappingAction = new Action <IOneToManyMapper>(mapper => { mapper.Class(refEntity.ClrType); }); var next = new PropertyPath(currentPropertyPath, property.ClrPropertyInfo); customizerHolder.AddCustomizer(next, o2mMappingAction); customizerHolder.AddCustomizer(next, bagMappingAction); modelExplicitDeclarationsHolder.AddAsOneToManyRelation(property.ClrPropertyInfo); modelExplicitDeclarationsHolder.AddAsBag(property.ClrPropertyInfo); }
public override void MapField( ICustomizersHolder customizerHolder, IModelExplicitDeclarationsHolder modelExplicitDeclarationsHolder, PropertyPath currentPropertyPath, MetaEntity entity, MetaField field) { var primitiveProperty = (PrimitiveMetaField)field; var mappingAction = new Action <IPropertyMapper>(mapper => { if (field.MaxLength != null && field.MaxLength > 0) { mapper.Length(field.MaxLength.Value); } else { mapper.Type(NHibernateUtil.StringClob); } mapper.Column(field.DbName); mapper.Unique(field.IsUnique); mapper.Lazy(field.IsLazy); mapper.NotNullable(primitiveProperty.IsRequired); }); var next = new PropertyPath(currentPropertyPath, field.ClrPropertyInfo); customizerHolder.AddCustomizer(next, mappingAction); modelExplicitDeclarationsHolder.AddAsProperty(field.ClrPropertyInfo); }
public void Property <TProperty>(Expression <Func <TPersistent, TProperty> > property, Action <IPropertyMapper> mapping) { var member = TypeExtensions.DecodeMemberAccessExpression(property); customizersHolder.AddCustomizer(new PropertyPath(null, member), mapping); var memberOf = TypeExtensions.DecodeMemberAccessExpressionOf(property); customizersHolder.AddCustomizer(new PropertyPath(null, memberOf), mapping); }
public override void MapField(ICustomizersHolder customizerHolder, IModelExplicitDeclarationsHolder modelExplicitDeclarationsHolder, PropertyPath currentPropertyPath, MetaEntity entity, MetaField property) { var m2oProperty = property as ManyToOneMetaField; var mappingAction = new Action <IManyToOneMapper>(mapper => { mapper.Column(property.DbName); mapper.NotNullable(m2oProperty.IsRequired); }); var next = new PropertyPath(currentPropertyPath, property.ClrPropertyInfo); customizerHolder.AddCustomizer(next, mappingAction); modelExplicitDeclarationsHolder.AddAsManyToOneRelation(property.ClrPropertyInfo); }
public override void MapField(ICustomizersHolder customizerHolder, IModelExplicitDeclarationsHolder modelExplicitDeclarationsHolder, PropertyPath currentPropertyPath, MetaEntity entity, MetaField field) { var mappingAction = new Action <IClassMapper>(mapper => { mapper.Id(idMapper => { idMapper.Column(field.DbName); }); }); var next = new PropertyPath(currentPropertyPath, field.ClrPropertyInfo); customizerHolder.AddCustomizer(field.ClrPropertyInfo.DeclaringType, mappingAction); modelExplicitDeclarationsHolder.AddAsPoid(field.ClrPropertyInfo); }
public override void MapField(ICustomizersHolder customizerHolder, IModelExplicitDeclarationsHolder modelExplicitDeclarationsHolder, PropertyPath currentPropertyPath, MetaEntity entity, MetaField field) { var genericHibernateEnumTypeType = typeof(global::NHibernate.Type.EnumStringType <>); var hibernateEnumTypeType = genericHibernateEnumTypeType.MakeGenericType(field.ClrPropertyInfo.PropertyType); var hibernateEnumType = Activator.CreateInstance(hibernateEnumTypeType) as IType; var primitiveField = (EnumerableMetaField)field; var mappingAction = new Action <global::NHibernate.Mapping.ByCode.IPropertyMapper>(mapper => { mapper.Column(field.DbName); mapper.Type(hibernateEnumType); mapper.NotNullable(primitiveField.IsRequired); }); var next = new PropertyPath(currentPropertyPath, field.ClrPropertyInfo); customizerHolder.AddCustomizer(next, mappingAction); modelExplicitDeclarationsHolder.AddAsProperty(field.ClrPropertyInfo); }
public override void MapField(ICustomizersHolder customizerHolder, IModelExplicitDeclarationsHolder modelExplicitDeclarationsHolder, PropertyPath currentPropertyPath, MetaEntity entity, MetaField field) { var mappingAction = new Action <IPropertyMapper>(mapper => { var userType = this.MakeTextBasedJsonType(field.ClrPropertyInfo.PropertyType); mapper.Type(userType, null); mapper.Unique(false); mapper.Lazy(field.IsLazy); mapper.Column(field.DbName); mapper.NotNullable(field is IMetaFieldWithIsRequired fr && fr.IsRequired); if (field.MaxLength != null && field.MaxLength > 0) { mapper.Length(field.MaxLength.Value); } }); var next = new PropertyPath(currentPropertyPath, field.ClrPropertyInfo); customizerHolder.AddCustomizer(next, mappingAction); modelExplicitDeclarationsHolder.AddAsProperty(field.ClrPropertyInfo); }
public void Column(Action <IColumnMapper> columnMapper) { customizersHolder.AddCustomizer(propertyPath, (IMapKeyManyToManyMapper x) => x.Column(columnMapper)); }
public void MetaType(IType metaType) { customizersHolder.AddCustomizer(propertyPath, (IManyToAnyMapper x) => x.MetaType(metaType)); }
public void Class(System.Type entityType) { customizersHolder.AddCustomizer(propertyPath, (IOneToManyMapper x) => x.Class(entityType)); }
public void Parent <TProperty>(Expression <Func <TComponent, TProperty> > parent) where TProperty : class { MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(parent); customizersHolder.AddCustomizer(typeof(TComponent), (IComponentAttributesMapper x) => x.Parent(member)); }
public void Parent <TProperty>(Expression <Func <TComponent, TProperty> > parent, Action <IComponentParentMapper> parentMapping) where TProperty : class { MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(parent); customizersHolder.AddCustomizer(typeof(TComponent), (IComponentAttributesMapper x) => x.Parent(member, parentMapping)); explicitDeclarationsHolder.AddAsPersistentMember(member); }
public void Parent(string notVisiblePropertyOrFieldName, Action <IComponentParentMapper> parentMapping) { MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVisiblePropertyOrFieldName); _customizersHolder.AddCustomizer(typeof(TComponent), (IComponentAttributesMapper x) => x.Parent(member, parentMapping)); _explicitDeclarationsHolder.AddAsPersistentMember(member); }
public void Property <TProperty>(Expression <Func <TKey, TProperty> > property, Action <IPropertyMapper> mapping) { MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property); customizersHolder.AddCustomizer(new PropertyPath(propertyPath, member), mapping); }