public void Property(string notVisiblePropertyOrFieldName, Action <IPropertyMapper> mapping) { MemberInfo member = GetPropertyOrFieldMatchingNameOrThrow(notVisiblePropertyOrFieldName); MemberInfo memberOf = member.GetMemberFromReflectedType(typeof(TComponent)); _customizersHolder.AddCustomizer(new PropertyPath(_propertyPath, member), mapping); _explicitDeclarationsHolder.AddAsProperty(memberOf); }
public void Property <TProperty>(Expression <Func <TComponent, TProperty> > property, Action <IPropertyMapper> mapping) { MemberInfo member = TypeExtensions.DecodeMemberAccessExpression(property); customizersHolder.AddCustomizer(new PropertyPath(propertyPath, member), mapping); MemberInfo memberOf = TypeExtensions.DecodeMemberAccessExpressionOf(property); customizersHolder.AddCustomizer(new PropertyPath(propertyPath, memberOf), mapping); explicitDeclarationsHolder.AddAsProperty(member); explicitDeclarationsHolder.AddAsProperty(memberOf); }
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); }
protected void RegistePropertyMapping(Action <IPropertyMapper> mapping, params MemberInfo[] members) { foreach (var member in members) { CustomizersHolder.AddCustomizer(new PropertyPath(PropertyPath, member), mapping); explicitDeclarationsHolder.AddAsProperty(member); } }
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 static void Merge(this IModelExplicitDeclarationsHolder destination, IModelExplicitDeclarationsHolder source) { if (destination == null || source == null) { return; } foreach (var o in source.RootEntities) { destination.AddAsRootEntity(o); } foreach (var o in source.Components) { destination.AddAsComponent(o); } foreach (var o in source.TablePerClassEntities) { destination.AddAsTablePerClassEntity(o); } foreach (var o in source.TablePerClassHierarchyEntities) { destination.AddAsTablePerClassHierarchyEntity(o); } foreach (var o in source.TablePerConcreteClassEntities) { destination.AddAsTablePerConcreteClassEntity(o); } foreach (var o in source.OneToOneRelations) { destination.AddAsOneToOneRelation(o); } foreach (var o in source.ManyToOneRelations) { destination.AddAsManyToOneRelation(o); } foreach (var o in source.KeyManyToManyRelations) { destination.AddAsManyToManyKeyRelation(o); } foreach (var o in source.ItemManyToManyRelations) { destination.AddAsManyToManyItemRelation(o); } foreach (var o in source.ManyToAnyRelations) { destination.AddAsManyToAnyRelation(o); } foreach (var o in source.OneToManyRelations) { destination.AddAsOneToManyRelation(o); } foreach (var o in source.Any) { destination.AddAsAny(o); } foreach (var o in source.Poids) { destination.AddAsPoid(o); } foreach (var o in source.ComposedIds) { destination.AddAsPartOfComposedId(o); } foreach (var o in source.VersionProperties) { destination.AddAsVersionProperty(o); } foreach (var o in source.NaturalIds) { destination.AddAsNaturalId(o); } foreach (var o in source.Sets) { destination.AddAsSet(o); } foreach (var o in source.Bags) { destination.AddAsBag(o); } foreach (var o in source.IdBags) { destination.AddAsIdBag(o); } foreach (var o in source.Lists) { destination.AddAsList(o); } foreach (var o in source.Arrays) { destination.AddAsArray(o); } foreach (var o in source.Dictionaries) { destination.AddAsMap(o); } foreach (var o in source.Properties) { destination.AddAsProperty(o); } foreach (var o in source.PersistentMembers) { destination.AddAsPersistentMember(o); } foreach (var o in source.SplitDefinitions) { destination.AddAsPropertySplit(o); } foreach (var dynamicComponent in source.DynamicComponents) { var template = source.GetDynamicComponentTemplate(dynamicComponent); destination.AddAsDynamicComponent(dynamicComponent, template); } }