public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType.Equals(typeof(IGeometry)))
     {
         instance.CustomType<GeometryType>();
         instance.CustomSqlType("Geography");
     }
 }
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType.Equals(typeof(IGeometry)))
     {
         instance.CustomType <GeometryType>();
         instance.CustomSqlType("Geography");
     }
 }
 public void Apply(IPropertyInstance instance)
 {
     if (typeof(IGeometry).IsAssignableFrom(instance.Property.PropertyType))
     {
         instance.CustomType(typeof(GeographyType));
         instance.CustomSqlType("GEOGRAPHY");
     }
 }
Exemplo n.º 4
0
 public void Apply(IPropertyInstance instance)
 {
     if (typeof(IGeometry).IsAssignableFrom(instance.Property.PropertyType))
     {
         instance.CustomType(typeof(GeographyType));
         instance.CustomSqlType("GEOGRAPHY");
     }
 }
Exemplo n.º 5
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.ToString().Contains("String"))
     {
         instance.CustomType("StringClob");
         instance.CustomSqlType("NTEXT");
         //instance.Length(4001);
     }
 }
Exemplo n.º 6
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();
        }
Exemplo n.º 7
0
        public void Apply(IPropertyInstance instance)
        {
            if (instance.Property.PropertyType == StringType && instance.EntityType.GetCustomAttribute <LengthAttribute>() == null && instance.SqlType == null)
            {
                instance.CustomSqlType("text");
            }

            if (instance.Property.MemberInfo.GetCustomAttribute <CitextAttribute>() != null)
            {
                instance.CustomSqlType("citext");

                return;
            }

            if (instance.Property.Name != "Id" && instance.EntityType.GetCustomAttribute <CitextAttribute>() != null)
            {
                instance.CustomSqlType("citext");
            }
        }
Exemplo n.º 8
0
        public void Apply(IPropertyInstance instance)
        {
            if (!instance.Property.PropertyType.IsSubclassOf(typeof(Geometry)))
            {
                return;
            }

            instance.CustomType <Wgs84GeometryType>();
            instance.CustomSqlType("geometry");
        }
Exemplo n.º 9
0
        public void Apply(IPropertyInstance instance)
        {
            var type = instance.Property.PropertyType;

            if (type == typeof(DateTime) || type == typeof(DateTime?))
            {
                instance.CustomType("timestamp");
                instance.CustomSqlType("datetime2");
            }
        }
Exemplo n.º 10
0
        public void Apply(IPropertyInstance instance)
        {
            var type = instance.Property.PropertyType;

            if (type == typeof(XElement))
            {
                instance.CustomType <XElementUserType>();
                instance.CustomSqlType("varchar(4000)");
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Applies CustomSqlType for Date and time columns.
        /// </summary>
        /// <param name="propertyInstance">The property instance.</param>
        /// <param name="columnName">Name of the column.</param>
        public static void Apply(IPropertyInstance propertyInstance, string columnName)
        {
            if (propertyInstance.Type == typeof(DateTime))
            {
                propertyInstance.CustomSqlType("DATETIME");
            }

            if (propertyInstance.Type == typeof(DateTime?))
            {
                propertyInstance.Nullable();
                propertyInstance.CustomSqlType("DATETIME");
            }
            if (propertyInstance.Type == typeof(DateTimeOffset?))
            {
                propertyInstance.Nullable();
                propertyInstance.CustomSqlType("DATETIME");
            }



            //columnName = columnName.ToLower ();

            //if ( columnName.EndsWith ( "timestamp" ) )
            //{
            //    propertyInstance.CustomSqlType ( "datetimeoffset" );
            //}
            //else if ( columnName.EndsWith ( "datetime" ) )
            //{
            //    //TODO: Property ending with DateTime will use datetimeoffset in future.
            //    //     Do not remove this condition or it'll pick Time as its type from the next condition
            //    //instance.CustomSqlType ( "datetimeoffset" );
            //}
            //else if ( columnName.EndsWith ( "date" ) )
            //{
            //    propertyInstance.CustomSqlType ( "date" );
            //}
            //else if ( columnName.EndsWith ( "time" ) )
            //{
            //    propertyInstance.CustomSqlType ( "time" );
            //}
        }
        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 + ")");
        }
Exemplo n.º 13
0
        protected override void Apply(TextAttribute attribute, IPropertyInstance instance)
        {
            var maxLength = attribute.MaxLength;

            if (instance.Property.PropertyType == typeof(string) && maxLength == int.MaxValue)
            {
                instance.CustomSqlType("text");
            }
            else
            {
                instance.Length(maxLength);
            }
        }
        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 + ")");
        }
Exemplo n.º 15
0
        private static bool SetCustomType(IPropertyInstance instance, Type type)
        {
            if (type == typeof(IReadOnlyList <int>))
            {
                instance.CustomType <ListIntType>();
                instance.CustomSqlType("integer[]");
                return(true);
            }
            if (type == typeof(IReadOnlyList <short>))
            {
                instance.CustomType <ListShortType>();
                instance.CustomSqlType("smallint[]");
                return(true);
            }
            if (type == typeof(IReadOnlyList <string>))
            {
                instance.CustomType <ListStringType>();
                instance.CustomSqlType("text[]");
                return(true);
            }

            return(false);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Applies CustomSqlType for Date and time columns.
        /// </summary>
        /// <param name="propertyInstance">The property instance.</param>
        /// <param name="columnName">Name of the column.</param>
        public static void Apply(IPropertyInstance propertyInstance, string columnName)
        {
            columnName = columnName.ToLower();

            if (columnName.EndsWith("timestamp"))
            {
                propertyInstance.CustomSqlType("datetimeoffset");
            }
            else if (columnName.EndsWith("datetime"))
            {
                //TODO: Property ending with DateTime will use datetimeoffset in future.
                //     Do not remove this condition or it'll pick Time as its type from the next condition
                //instance.CustomSqlType ( "datetimeoffset" );
            }
            else if (columnName.EndsWith("date"))
            {
                propertyInstance.CustomSqlType("date");
            }
            else if (columnName.EndsWith("time"))
            {
                propertyInstance.CustomSqlType("time");
            }
        }
Exemplo n.º 17
0
        public void Apply(IPropertyInstance instance)
        {
            if (instance.Property.PropertyType == typeof(byte[]))
            {
                instance.
                CustomSqlType("varbinary(max)");

                instance.
                Length(Int32.MaxValue);

                instance.
                LazyLoad();
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Applies CustomSqlType for Date and time columns.
        /// </summary>
        /// <param name="propertyInstance">The property instance.</param>
        /// <param name="columnName">Name of the column.</param>
        public static void Apply( IPropertyInstance propertyInstance, string columnName )
        {
            columnName = columnName.ToLower ();

            if ( columnName.EndsWith ( "timestamp" ) )
            {
                propertyInstance.CustomSqlType ( "datetimeoffset" );
            }
            else if ( columnName.EndsWith ( "datetime" ) )
            {
                //TODO: Property ending with DateTime will use datetimeoffset in future.
                //     Do not remove this condition or it'll pick Time as its type from the next condition
                //instance.CustomSqlType ( "datetimeoffset" );
            }
            else if ( columnName.EndsWith ( "date" ) )
            {
                propertyInstance.CustomSqlType ( "date" );
            }
            else if ( columnName.EndsWith ( "time" ) )
            {
                propertyInstance.CustomSqlType ( "time" );
            }
        }
Exemplo n.º 19
0
        public void Apply(IPropertyInstance instance)
        {
            // Default behaviour: any column can be null

            if (instance.Property.MemberInfo.GetAttribute <AllowNullAttribute>() != null)
            {
                instance.Nullable();
            }
            else
            {
                instance.Not.Nullable();
            }

            if (instance.Type == typeof(DateTime))
            {
                instance.CustomSqlType("DateTime2");
            }

            if (instance.Type == typeof(DateTime?))
            {
                instance.Nullable();
                instance.CustomSqlType("DateTime2");
            }
        }
Exemplo n.º 20
0
        public void Apply(IPropertyInstance instance)
        {
            // Default behaviour: any column can be null

            if (instance.Property.MemberInfo.GetAttribute<AllowNullAttribute>() != null)
            {
                instance.Nullable();
            }
            else
            {
                instance.Not.Nullable();
            }

            if (instance.Type == typeof(DateTime))
            {
                instance.CustomSqlType("DateTime2");
            }

            if (instance.Type == typeof(DateTime?))
            {
                instance.Nullable();
                instance.CustomSqlType("DateTime2");
            }
        }
        public static void HasLengthAttributes(this IPropertyInstance instance)
        {
            if (instance == null)
            {
                return;
            }

            var max = (from attribute
                       in instance.Property.MemberInfo.GetCustomAttributes(typeof(StringLengthAttribute), false)
                       select(StringLengthAttribute) attribute into result
                       select result.MaximumLength).FirstOrDefault();

            if (max > 0)
            {
                instance.CustomSqlType($"varchar({max})");
            }
        }
Exemplo n.º 22
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType("StringClob");
     instance.CustomSqlType("nvarchar(max)");
 }
Exemplo n.º 23
0
		public void Apply(IPropertyInstance instance)
		{
			instance.CustomSqlType("tinyint");
		}
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType("StringClob");
     instance.CustomSqlType("text");
 }
Exemplo n.º 25
0
 public void Apply(IPropertyInstance instance)
 {
     instance.Length(2147483647);
     instance.CustomSqlType("varbinary(MAX)");
 }
Exemplo n.º 26
0
 protected override void Apply(StringLengthAttribute attribute, IPropertyInstance instance)
 {
     instance.CustomSqlType("varbinary(MAX)");
     instance.Length(attribute.MaximumLength);
 }
Exemplo n.º 27
0
 public void Apply(IPropertyInstance target)
 {
     target.CustomType(typeof(MsSql2008GeometryType));
     target.CustomSqlType("GEOMETRY");
 }
Exemplo n.º 28
0
 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)
        {
            var list = instance.Property.MemberInfo.GetCustomAttributes(typeof(ColumnAttribute), true);

            if (!list.Any())
            {
                return;
            }
            var attr = (ColumnAttribute)list.FirstOrDefault();

            if (attr != null)
            {
                if (!string.IsNullOrEmpty(attr.Name))
                {
                    instance.Column(attr.Name);
                }
                if (string.IsNullOrEmpty(attr.TypeName))
                {
                    return;
                }
                if (_config.DbProvider == DbProvider.MySql)
                {
                    var typename = attr.TypeName.ToLower();
                    if (typename == "ntext")
                    {
                        instance.CustomSqlType("text");
                    }
                    else if (typename == "nvarchar")
                    {
                        instance.CustomSqlType("varchar");
                    }
                    else if (typename == "nchar")
                    {
                        instance.CustomSqlType("char");
                    }
                    else
                    {
                        instance.CustomSqlType(typename);
                    }
                }
                else if (_config.DbProvider == DbProvider.SqlServer)
                {
                    var typename = attr.TypeName.ToLower();
                    if (typename == "text")
                    {
                        instance.CustomSqlType("ntext");
                    }
                    else if (typename == "varchar")
                    {
                        instance.CustomSqlType("nvarchar");
                    }
                    else if (typename == "char")
                    {
                        instance.CustomSqlType("nchar");
                    }
                    else
                    {
                        instance.CustomSqlType(typename);
                    }
                }
                else
                {
                    instance.CustomSqlType(attr.TypeName);
                }
            }
        }
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Type == typeof(DateTime))
         instance.CustomSqlType("datetime2");
 }
Exemplo n.º 31
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomSqlType("DateTime2"); //specify that the sql column is DateTime2
     instance.CustomType("DateTime2");    //set the nhib type as well
 }
Exemplo n.º 32
0
 protected override void Apply(FixedLengthUnicodeStringAttribute attribute, IPropertyInstance instance)
 {
     instance.CustomSqlType($"nchar({attribute.Length})");
 }
Exemplo n.º 33
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomSqlType("DateTime2");
     instance.CustomType("DateTime2");
 }
Exemplo n.º 34
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomSqlType("text COLLATE NOCASE");
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomSqlType("numeric");
     instance.Precision(10);
     instance.Scale(2);
 }
Exemplo n.º 36
0
 /// <summary>
 /// The SQL type is set by default to TINYINT but this can be overridden by the EnumSqlType configuration key.
 /// </summary>
 public void Apply(IPropertyInstance target)
 {
     target.CustomType(target.Property.PropertyType);
     target.CustomSqlType(enumSqlType);
 }
Exemplo n.º 37
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomSqlType("timestamp");
 }
Exemplo n.º 38
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomSqlType("tinyint");
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.Length(2147483647);
     instance.CustomSqlType("varbinary(MAX)");
 }