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"); } }
public void Apply(IPropertyInstance instance) { if (instance.Property.ToString().Contains("String")) { instance.CustomType("StringClob"); instance.CustomSqlType("NTEXT"); //instance.Length(4001); } }
/// <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 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"); } }
public void Apply(IPropertyInstance instance) { if (!instance.Property.PropertyType.IsSubclassOf(typeof(Geometry))) { return; } instance.CustomType <Wgs84GeometryType>(); instance.CustomSqlType("geometry"); }
public void Apply(IPropertyInstance instance) { var type = instance.Property.PropertyType; if (type == typeof(DateTime) || type == typeof(DateTime?)) { instance.CustomType("timestamp"); instance.CustomSqlType("datetime2"); } }
public void Apply(IPropertyInstance instance) { var type = instance.Property.PropertyType; if (type == typeof(XElement)) { instance.CustomType <XElementUserType>(); instance.CustomSqlType("varchar(4000)"); } }
/// <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 + ")"); }
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); } }
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); }
/// <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"); } }
public void Apply(IPropertyInstance instance) { if (instance.Property.PropertyType == typeof(byte[])) { instance. CustomSqlType("varbinary(max)"); instance. Length(Int32.MaxValue); instance. LazyLoad(); } }
/// <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" ); } }
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 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})"); } }
public void Apply(IPropertyInstance instance) { instance.CustomType("StringClob"); instance.CustomSqlType("nvarchar(max)"); }
public void Apply(IPropertyInstance instance) { instance.CustomSqlType("tinyint"); }
public void Apply(IPropertyInstance instance) { instance.CustomType("StringClob"); instance.CustomSqlType("text"); }
public void Apply(IPropertyInstance instance) { instance.Length(2147483647); instance.CustomSqlType("varbinary(MAX)"); }
protected override void Apply(StringLengthAttribute attribute, IPropertyInstance instance) { instance.CustomSqlType("varbinary(MAX)"); instance.Length(attribute.MaximumLength); }
public void Apply(IPropertyInstance target) { target.CustomType(typeof(MsSql2008GeometryType)); target.CustomSqlType("GEOMETRY"); }
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"); }
public void Apply(IPropertyInstance instance) { instance.CustomSqlType("DateTime2"); //specify that the sql column is DateTime2 instance.CustomType("DateTime2"); //set the nhib type as well }
protected override void Apply(FixedLengthUnicodeStringAttribute attribute, IPropertyInstance instance) { instance.CustomSqlType($"nchar({attribute.Length})"); }
public void Apply(IPropertyInstance instance) { instance.CustomSqlType("DateTime2"); instance.CustomType("DateTime2"); }
public void Apply(IPropertyInstance instance) { instance.CustomSqlType("text COLLATE NOCASE"); }
public void Apply(IPropertyInstance instance) { instance.CustomSqlType("numeric"); instance.Precision(10); instance.Scale(2); }
/// <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); }
public void Apply(IPropertyInstance instance) { instance.CustomSqlType("timestamp"); }