private static void ApplyStringLength(int stringLength, IPropertyInstance target) { if (stringLength > 0) { target.Length(stringLength); } }
private static void ApplyRequired(bool required, IPropertyInstance target) { if (required) { target.Not.Nullable(); } }
public void Apply(IPropertyInstance instance) { if (Nullable.GetUnderlyingType(instance.Property.PropertyType) == null) { instance.Not.Nullable(); } }
public void Apply(IPropertyInstance instance) { if (instance.Property != null) { instance.Property.Name.Camelize(); } }
public void Apply(IPropertyInstance instance) { if (instance.Property.IsNotNull()) { instance.Column(instance.Property.Name.ToCamelCase()); } }
public void Apply(IPropertyInstance target) { var att = Attribute.GetCustomAttribute(target.Property.MemberInfo, typeof(RequiredAttribute)) as RequiredAttribute; if (att != null) target.Not.Nullable(); }
/// <summary> /// Applies Index based on type. /// </summary> /// <param name="instance">The instance.</param> public void Apply( IPropertyInstance instance ) { CreateUniqeIndexIfIndicated ( instance.Property, instance.Unique, instance.UniqueKey ); var sourceName = instance.EntityType.Name; var propertyName = instance.Property.Name; if ( typeof( ILookup ).IsAssignableFrom ( instance.EntityType ) ) { sourceName += "Lkp"; } if ( typeof( ILookup ).IsAssignableFrom ( instance.Property.PropertyType ) ) { propertyName += "Lkp"; } var indexAttribute = instance.Property.MemberInfo.GetCustomAttributes ( typeof( NaturalIndexAttribute ), false ); if ( indexAttribute.Length > 0 ) { var indexName = string.Format ( "{0}_{1}_IDX", sourceName, propertyName ); instance.Index ( indexName ); } }
public void Apply(IPropertyInstance instance) { if (instance.Property.PropertyType.Equals(typeof(IGeometry))) { instance.CustomType<SqLiteGeometryType>(); } }
public void Apply(IPropertyInstance instance) { if (typeof(IGeometry).IsAssignableFrom(instance.Property.PropertyType)) { instance.CustomType(typeof(GeographyType)); instance.CustomSqlType("GEOGRAPHY"); } }
public void Apply(IPropertyInstance instance) { if (instance.Property.Name == "Guid" && instance.Property.PropertyType == typeof (Guid)) { instance.Access.ReadOnlyPropertyThroughCamelCaseField(CamelCasePrefix.Underscore); instance.Index(string.Format("IX_{0}_{1}", instance.EntityType.Name, instance.Property.Name)); } }
public void Apply(IPropertyInstance instance) { if (instance.Type == typeof (decimal) || Nullable.GetUnderlyingType(instance.Property.PropertyType) == typeof(decimal)) { instance.Precision(27); instance.Scale(15); } }
public void Apply(IPropertyInstance instance) { if (instance.Name=="Name") { instance.Length(100); instance.Not.Nullable(); } }
public void Apply(IPropertyInstance instance) { var abbreviation = AttributeHelper.GetTypeAttribute<AbbreviationAttribute>(instance.EntityType); var columnName = abbreviation == null ? instance.Name : abbreviation.Abbreviation + instance.Name; instance.Column(columnName.EscapeColumnName()); }
public void Apply(IPropertyInstance instance) { if (instance.Property.PropertyType.Equals(typeof(IGeometry))) { instance.CustomType<GeometryType>(); instance.CustomSqlType("Geography"); } }
public void Apply(IPropertyInstance instance) { var attribute = instance.Property.MemberInfo.GetCustomAttribute<NotNullableAttribute>(); if (attribute != null) { instance.Not.Nullable(); } }
/// <summary> /// Applies this column name convention to the specified <see cref = "IPropertyInstance" />. /// </summary> /// <param name="instance">An <see cref = "IPropertyInstance" />.</param> public void Apply(IPropertyInstance instance) { if (instance == null) { throw new ArgumentNullException("instance"); } instance.Column(instance.Property.Name); }
/// <summary> /// The convention that is applied to a <see cref = "IPropertyInstance" /> when the criteria from the Accept method is meet. /// </summary> /// <param name="instance">An <see cref = "IPropertyInstance" /> to apply the convention to.</param> public void Apply(IPropertyInstance instance) { if (instance == null) { throw new ArgumentNullException("instance"); } instance.CustomType<DateTimeOffsetSplitType>(); }
public void Apply(IPropertyInstance instance) { if (instance.Property.MemberInfo.IsDefined(typeof(RequiredAttribute), false)) instance.Not.Nullable(); else if (Nullable.GetUnderlyingType(instance.Property.PropertyType) != null || instance.Property.PropertyType == typeof(string)) instance.Nullable(); else instance.Not.Nullable(); }
/// <summary> /// Applies the specified instance. /// </summary> /// <param name="instance">The instance.</param> public void Apply(IPropertyInstance instance) { if (instance == null) { throw new ArgumentNullException("instance"); } instance.CustomType(instance.Property.PropertyType); }
public void Apply(IPropertyInstance instance) { if (instance.Property.ToString().Contains("String")) { instance.CustomType("StringClob"); instance.CustomSqlType("NTEXT"); //instance.Length(4001); } }
public void Apply(IPropertyInstance instance) { if (instance.Type.IsEnum == false) return; if (EnumType == EnumType.Integer) instance.CustomType<int>(); else instance.CustomType<string>(); }
/// <summary> /// Conventions for handling string properties in FluentNHibernate. If the property name contains any of the /// configured strings in BigStringPropertyNames, then the SQL type of the property is set to NVARCHAR(MAX); the /// SQL type can be overridden by the BigStringSqlType configuration key. Also adds a unique constraint for /// domain ids and external ids. /// </summary> public void Apply(IPropertyInstance instance) { // If property name contains one of the configured values, then use use special SQL type for column string name = instance.Name; if (bigStringPropertyNames.FirstOrDefault(name.Contains) != null) instance.CustomSqlType(bigStringSqlType); // Add unique constraint for domain ids and external ids if (name.Equals("DomainId")) instance.Unique(); if (name.Equals("ExternalId")) instance.Unique(); }
public void Apply(IPropertyInstance target) { var attribute = Attribute.GetCustomAttribute(target.Property.MemberInfo, typeof(StringLengthAttribute)) as StringLengthAttribute; if (attribute != null) { target.Length(attribute.MaximumLength); } }
public void Apply(IPropertyInstance instance) { int length = 255; var instanceProperties = instance as IPropertyInspector; if (instanceProperties != null) { var existingLength = instanceProperties.Length; length = existingLength == 0 ? length : existingLength; } instance.CustomSqlType("VarChar(" + length + ")"); }
public void Apply(IPropertyInstance instance) { var meta = query.GetMetadataFor(instance.EntityType,instance.Property.Name); if (meta.Required.HasValue) { ApplyRequired(meta.Required.Value, instance); } if (meta.StringLength.HasValue) { ApplyStringLength(meta.StringLength.Value, instance); } }
/// <summary> /// Applies the column name based on type. /// </summary> /// <param name="instance">The instance.</param> public void Apply( IPropertyInstance instance ) { if ( !instance.Property.DeclaringType.IsNHibernateComponent () ) { if ( instance.Property.PropertyType.IsEnum || instance.Property.PropertyType.IsNullableEnum () ) { var columnName = GetColumnNameForEnum ( instance.Property.Name ); instance.Column ( columnName ); } } }
private static void StringConvention(IPropertyInstance instance) { if (instance.Type == typeof (String)) { object[] attributes = instance.EntityType.GetProperty(instance.Name) .GetCustomAttributes(typeof (LengthAttribute), false); if (attributes.Length > 0) { LengthAttribute length = attributes[0] as LengthAttribute; if (length != null) instance.Length(length.Length); } } }
/// <summary> /// Applies nullablity based on type. /// </summary> /// <param name="instance">The instance.</param> public void Apply( IPropertyInstance instance ) { var entityType = instance.EntityType; if ( !entityType.IsNHibernateComponent () ) { var member = instance.Property; if ( !member.IsDbNullable () ) { instance.Not.Nullable (); } } }
public void Apply(IPropertyInstance propertyMapping) { try { if (propertyMapping.Type == typeof(byte[])) { propertyMapping.Length(int.MaxValue); } } catch (Exception e) { Debug.WriteLine(e); } }
/// <summary> /// Applies length based on byte[]. /// </summary> /// <param name="instance">The instance.</param> public void Apply( IPropertyInstance instance ) { var lengthAttributes = instance.Property.MemberInfo.GetCustomAttributes ( typeof( ColumnLengthAttribute ), false ); if ( lengthAttributes.Length > 0 ) { var columnLength = ( ColumnLengthAttribute )lengthAttributes[0]; instance.Length ( columnLength.Length ); } else { instance.Length ( ByteArrayDefaultLength ); } }
public void Apply(IPropertyInstance instance) { instance.Column(instance.Name.ToDatabaseName()); }
protected override void Apply(NotNullAttribute attribute, IPropertyInstance instance) { instance.Not.Nullable(); }
public void Apply(IPropertyInstance instance) { instance.CustomType <NHibernate.Type.XDocType>(); }
public void Apply(IPropertyInstance instance) { instance.Column(instance.Name + "1"); }
public void Apply(IPropertyInstance instance) { instance.Length(50); }
public void Apply(IPropertyInstance instance) { instance.CustomType(instance.Property.PropertyType); }
public void Apply(IPropertyInstance instance) { var name = NameConventions.ReplaceCamelCaseWithUnderscore(instance.Name); instance.Column(name.ToUpper()); }
public void Apply(IPropertyInstance instance) { Type closedType = _openType.MakeGenericType(instance.EntityType); instance.CustomType(closedType); }
public void Apply(IPropertyInstance instance) { instance.Column($"{Quote}{instance.Property.Name}{Quote}"); }
public void Apply(IPropertyInstance instance) { instance.CustomType(typeof(ByteType)); }
public virtual void Apply(IPropertyInstance instance) { Apply(instance.EntityType, instance.Name, instance.Access); }
public void Apply(IPropertyInstance instance) { instance.Update(); }
public void Apply(IPropertyInstance instance) { instance.Column("_" + instance.Name); }
public void Apply(IPropertyInstance instance) { instance.Column(EscapeColumn(instance.Name)); }
public void Apply(IPropertyInstance instance) { instance.CustomType <UtcDateTimeType>(); }
public void Apply(IPropertyInstance instance) { instance.CustomType("Timestamp"); }
public void Apply(IPropertyInstance target) { target.CustomSqlType(@"varchar(25)"); //TODO CDM //Type proxyType = Type.GetType(target.Name); //target.CustomSqlType(new EnumMapper().SqlType.ToString()); }
public void Apply(IPropertyInstance instance) { instance.CustomType <Vector3UserType>(); }
protected override void Apply(StringLengthAttribute attribute, IPropertyInstance instance) { instance.Length(attribute.MaximumLength); }
protected override void Apply(FormulaAttribute attribute, IPropertyInstance instance) { instance.Formula(attribute.SqlFormula); }
public void Apply(IPropertyInstance instance) { string columnName = GetColumnName(instance.Property.Name); instance.Column(columnName); }
public void Apply(IPropertyInstance instance) { instance.Length(10000); // needed for sql server (tested with versions 2005, 2008, 2014) }
public void Apply(IPropertyInstance instance) { instance.CustomType <DoubleStringType>(); }
public void Apply(IPropertyInstance instance) { instance.Not.Nullable(); }
protected override void Apply(UnicodeStringAttribute attribute, IPropertyInstance instance) { instance.Length(attribute.Length); }
public void Apply(IPropertyInstance instance) { instance.CustomType <DoubleStringType>(instance.Property.PropertyType.Name + "WithCustomPrefix_"); }
protected override void Apply(FilterCurrentLanguageAttribute attribute, IPropertyInstance instance) { // The real formula will be set in the NHMappings event listener. // We need to set the formula here in order to prevent fluent nh to create a column mapping. instance.Formula("Id"); }
public void Apply(IPropertyInstance target) { target.CustomType(target.Property.PropertyType); }
public void Apply(IPropertyInstance instance) { instance.CustomType(typeof(NullableTimeType)); }
public void Apply(IPropertyInstance instance) { instance.Column(ConvertToCustomName(instance.Property.Name)); }