コード例 #1
0
 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();
 }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: RequiredConvention.cs プロジェクト: fuding/yupi
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.MemberInfo.IsDefined(typeof(RequiredAttribute), true))
     {
         instance.Not.Nullable();
     }
     else
     {
         instance.Nullable();
     }
 }
コード例 #4
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" );
            //}
        }
コード例 #5
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");
            }
        }
コード例 #6
0
ファイル: PropertyConvention.cs プロジェクト: dwdkls/pizzamvc
        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");
            }
        }
コード例 #7
0
 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();
     }
 }
コード例 #8
0
        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);
        }
コード例 #9
0
 public void Apply(IPropertyInstance instance)
 {
     instance.Length(300);
     instance.Nullable();
 }
コード例 #10
0
 public void Apply(IPropertyInstance instance)
 {
     instance.CustomType("Timestamp");
     instance.Nullable();
     //  instance.Generated.Insert();
 }