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();
     }
 }
Ejemplo n.º 3
0
 public void Apply(IPropertyInstance instance)
 {
     if (Nullable.GetUnderlyingType(instance.Property.PropertyType) == null)
     {
         instance.Not.Nullable();
     }
 }
Ejemplo n.º 4
0
 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());
     }
 }
Ejemplo n.º 6
0
		public void Apply(IPropertyInstance target)
		{
            var att = Attribute.GetCustomAttribute(target.Property.MemberInfo, typeof(RequiredAttribute)) as RequiredAttribute;

			if (att != null)
				target.Not.Nullable();
		}
Ejemplo n.º 7
0
        /// <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");
     }
 }
Ejemplo n.º 10
0
 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));
     }
 }
Ejemplo n.º 11
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Type == typeof (decimal) || Nullable.GetUnderlyingType(instance.Property.PropertyType) == typeof(decimal))
     {
         instance.Precision(27);
         instance.Scale(15);
     }
 }
Ejemplo n.º 12
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Name=="Name")
     {
         instance.Length(100);
         instance.Not.Nullable();
     }
 }
Ejemplo n.º 13
0
		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");
     }
 }
Ejemplo n.º 15
0
 public void Apply(IPropertyInstance instance)
 {
     var attribute = instance.Property.MemberInfo.GetCustomAttribute<NotNullableAttribute>();
     if (attribute != null)
     {
         instance.Not.Nullable();
     }
 }
Ejemplo n.º 16
0
        /// <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();
 }
Ejemplo n.º 19
0
        /// <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);
        }
Ejemplo n.º 20
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.ToString().Contains("String"))
     {
         instance.CustomType("StringClob");
         instance.CustomSqlType("NTEXT");
         //instance.Length(4001);
     }
 }
Ejemplo n.º 21
0
        public void Apply(IPropertyInstance instance)
        {
            if (instance.Type.IsEnum == false)
                return;

            if (EnumType == EnumType.Integer)
                instance.CustomType<int>();
            else
                instance.CustomType<string>();
        }
Ejemplo n.º 22
0
        /// <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();
        }
Ejemplo n.º 23
0
        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);
     }
 }
Ejemplo n.º 26
0
 /// <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 );
         }
     }
 }
Ejemplo n.º 27
0
 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);
         }
     }
 }
Ejemplo n.º 28
0
        /// <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 );
            }
        }
Ejemplo n.º 31
0
 public void Apply(IPropertyInstance instance)
 {
     instance.Column(instance.Name.ToDatabaseName());
 }
 protected override void Apply(NotNullAttribute attribute, IPropertyInstance instance)
 {
     instance.Not.Nullable();
 }
Ejemplo n.º 33
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType <NHibernate.Type.XDocType>();
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.Column(instance.Name + "1");
 }
Ejemplo n.º 35
0
 public void Apply(IPropertyInstance instance)
 {
     instance.Length(50);
 }
Ejemplo n.º 36
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType(instance.Property.PropertyType);
 }
Ejemplo n.º 37
0
        public void Apply(IPropertyInstance instance)
        {
            var name = NameConventions.ReplaceCamelCaseWithUnderscore(instance.Name);

            instance.Column(name.ToUpper());
        }
Ejemplo n.º 38
0
        public void Apply(IPropertyInstance instance)
        {
            Type closedType = _openType.MakeGenericType(instance.EntityType);

            instance.CustomType(closedType);
        }
Ejemplo n.º 39
0
 public void Apply(IPropertyInstance instance)
 {
     instance.Column($"{Quote}{instance.Property.Name}{Quote}");
 }
Ejemplo n.º 40
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType(typeof(ByteType));
 }
Ejemplo n.º 41
0
 public virtual void Apply(IPropertyInstance instance)
 {
     Apply(instance.EntityType, instance.Name, instance.Access);
 }
Ejemplo n.º 42
0
 public void Apply(IPropertyInstance instance)
 {
     instance.Update();
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.Column("_" + instance.Name);
 }
Ejemplo n.º 44
0
 public void Apply(IPropertyInstance instance)
 {
     instance.Column(EscapeColumn(instance.Name));
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType <UtcDateTimeType>();
 }
Ejemplo n.º 46
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType("Timestamp");
 }
Ejemplo n.º 47
0
 public void Apply(IPropertyInstance target)
 {
     target.CustomSqlType(@"varchar(25)"); //TODO CDM
     //Type proxyType = Type.GetType(target.Name);
     //target.CustomSqlType(new EnumMapper().SqlType.ToString());
 }
Ejemplo n.º 48
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType <Vector3UserType>();
 }
Ejemplo n.º 49
0
 protected override void Apply(StringLengthAttribute attribute, IPropertyInstance instance)
 {
     instance.Length(attribute.MaximumLength);
 }
 protected override void Apply(FormulaAttribute attribute, IPropertyInstance instance)
 {
     instance.Formula(attribute.SqlFormula);
 }
Ejemplo n.º 51
0
        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)
 }
Ejemplo n.º 53
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType <DoubleStringType>();
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.Not.Nullable();
 }
Ejemplo n.º 55
0
 protected override void Apply(UnicodeStringAttribute attribute, IPropertyInstance instance)
 {
     instance.Length(attribute.Length);
 }
Ejemplo n.º 56
0
 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");
 }
Ejemplo n.º 58
0
 public void Apply(IPropertyInstance target)
 {
     target.CustomType(target.Property.PropertyType);
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType(typeof(NullableTimeType));
 }
Ejemplo n.º 60
0
 public void Apply(IPropertyInstance instance)
 {
     instance.Column(ConvertToCustomName(instance.Property.Name));
 }