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(); }
public void Apply(IPropertyInstance instance) { instance.CustomType <BinaryBlobType>(); instance.Nullable(); // Length is set because the NHibernate BinaryBlobType only specifies the SQL type as "binary", defaulting to a max length of 8000 instance.Length(int.MaxValue); lazyLoadIfSpecified(instance); }
public void Apply(IPropertyInstance instance) { if (instance.Property.MemberInfo.IsDefined(typeof(RequiredAttribute), true)) { instance.Not.Nullable(); } else { instance.Nullable(); } }
/// <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) { // 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 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(); } }
private static bool ProcessEnumTypes(IPropertyInstance instance) { if (instance.Type.IsEnum) { if (instance.Property.PropertyType.IsGenericType && instance.Property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable <>)) { instance.Nullable(); } else { instance.Not.Nullable(); } instance.CustomType(typeof(GenericPersistentEnumType <>) .CreateGenericType(instance.Type.GetGenericArguments()[0])); return(true); } return(false); }
public void Apply(IPropertyInstance instance) { instance.Length(300); instance.Nullable(); }
public void Apply(IPropertyInstance instance) { instance.CustomType("Timestamp"); instance.Nullable(); // instance.Generated.Insert(); }