public virtual void Apply(IPropertyInstance instance)
        {
            var customAttribute = instance.Property.MemberInfo.GetCustomAttribute(typeof(ColumnAttribute)) as ColumnAttribute;

            instance.Column(customAttribute != null ? customAttribute.Name : instance.Property.Name);
            var notInsertAttribute = instance.Property.MemberInfo.GetCustomAttribute(typeof(NotInsertAttribute)) as NotInsertAttribute;

            if (notInsertAttribute != null)
            {
                instance.Not.Insert();
            }
            var notUpdateAttribute = instance.Property.MemberInfo.GetCustomAttribute(typeof(NotUpdateAttribute)) as NotUpdateAttribute;

            if (notUpdateAttribute != null)
            {
                instance.Not.Update();
            }
            var nvarcharMaxAttribute = instance.Property.MemberInfo.GetCustomAttribute(typeof(NvarcharMaxAttribute)) as NvarcharMaxAttribute;

            if (nvarcharMaxAttribute != null)
            {
                instance.Length(4001);
                instance.CustomSqlType("nvarchar(max)");
            }
            var varbinaryMaxAttribute = instance.Property.MemberInfo.GetCustomAttribute(typeof(VarbinaryMaxAttribute)) as VarbinaryMaxAttribute;

            if (varbinaryMaxAttribute != null)
            {
                instance.Length(2147483647);
                instance.CustomSqlType("varbinary(max)");
            }
        }
Example #2
0
        private bool ProcessStringTypes(IPropertyInstance instance)
        {
            if (instance.Type == typeof(string) || instance.Type == typeof(PageNameUserType))
            {
                int length;
                if (HasMaxLengthAttribute(instance, out length) ||
                    HasStringLengthAttribute(instance, out length))
                {
                    // TODO: based on sqlserver, sqlite?
                    if (length <= 4000)
                    {
                        instance.CustomSqlType(string.Format("nvarchar({0})", length));
                        instance.Length(length);
                    }
                    else
                    {
                        instance.CustomSqlType("ntext");
                        instance.Length(4001);
                    }
                    return(true);
                }
                ConventionBasedLengthAssignment(instance);
                return(true);
            }

            return(false);
        }
 protected override void Apply(LengthAttribute attribute, IPropertyInstance instance)
 {
     //http://stackoverflow.com/questions/2343105/override-for-fluent-nhibernate-for-long-text-strings-nvarcharmax-not-nvarchar
     if (instance.Type != typeof(byte[]))
     {
         instance.Length(attribute.Max == int.MaxValue ? 10000 : attribute.Max);
     }
     else
     {
         instance.Length(attribute.Max);
     }
 }
        /// <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 );
            }
        }
Example #5
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType == typeof(string))
     {
         instance.Length(150);
     }
 }
Example #6
0
 private static void ApplyStringLength(int stringLength, IPropertyInstance target)
 {
     if (stringLength > 0)
     {
         target.Length(stringLength);
     }
 }
 private static void ApplyStringLength(int stringLength, IPropertyInstance target)
 {
     if (stringLength > 0)
     {
         target.Length(stringLength);
     }
 }
Example #8
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType != typeof(string))
         return;
     var memberInfo = instance.Property.MemberInfo;
     var stringLengthAttribute = memberInfo.GetCustomAttribute<StringLengthAttribute>();
     var isDbLengthAttribute = memberInfo.GetCustomAttribute<IsDBLengthAttribute>();
     if (stringLengthAttribute != null && isDbLengthAttribute != null)
     {
         instance.Length(stringLengthAttribute.MaximumLength);
     }
     else
     {
         instance.CustomType<VarcharMax>();
         instance.Length(4001);
     }
 }
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Name=="Name")
     {
         instance.Length(100);
         instance.Not.Nullable();
     }
 }
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Name == "Name")
     {
         instance.Length(100);
         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);
        }
Example #12
0
        public void Apply(IPropertyInstance instance)
        {
            int leng = 255;

            MemberInfo[] myMemberInfos = ((PropertyInstance)(instance)).EntityType.GetMember(instance.Name);
            if (myMemberInfos.Length > 0)
            {
                object[] myCustomAttrs = myMemberInfos[0].GetCustomAttributes(false);
                if (myCustomAttrs.Length > 0)
                {
                    if (myCustomAttrs[0] is MyDomain.DBDecorations.StringLength)
                    {
                        leng = ((MyDomain.DBDecorations.StringLength)(myCustomAttrs[0])).Length;
                        instance.Length(leng);
                    }
                }
            }
            instance.Length(leng);
        }
Example #13
0
        public void Apply(IPropertyInstance target)
        {
            var attribute =
                Attribute.GetCustomAttribute(target.Property.MemberInfo, typeof(StringLengthAttribute)) as
                StringLengthAttribute;

            if (attribute != null)
            {
                target.Length(attribute.MaximumLength);
            }
        }
Example #14
0
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Property.PropertyType == typeof(string))
     {
         instance.CustomType("AnsiString");
         instance.Length(500);
     }
     else if (instance.Property.PropertyType == typeof(decimal))
     {
         instance.Precision(18);
         instance.Scale(2);
     }
 }
        /// <summary>
        /// Sets the length of the property based on the Name.
        /// </summary>
        /// <param name="propertyInstance">The property instance.</param>
        /// <param name="columnName">Name of the column.</param>
        public static void Apply( IPropertyInstance propertyInstance, string columnName )
        {
            var lengthAttributes = propertyInstance.Property.MemberInfo.GetCustomAttributes (
                typeof( ColumnLengthAttribute ), false );

            if ( lengthAttributes.Length > 0 )
            {
                var columnLength = ( ColumnLengthAttribute )lengthAttributes[0];
                propertyInstance.Length ( columnLength.Length );
            }
            else if ( columnName.EndsWith ( "Code" ) )
            {
                propertyInstance.Length ( CodeLength );
            }
            else if ( columnName.EndsWith ( "Number" ) )
            {
                propertyInstance.Length ( NumberLength );
            }
            else if ( columnName.EndsWith ( "Name" ) )
            {
                propertyInstance.Length ( NameLength );
            }
            else if ( columnName.EndsWith ( "Note" ) )
            {
                propertyInstance.Length ( NoteLength );
            }
            else if ( columnName.EndsWith ( "Description" ) )
            {
                propertyInstance.Length ( DescriptionLength );
            }
            else if ( columnName.EndsWith ( "Identifier" ) )
            {
                propertyInstance.Length ( IdentifierLength );
            }
            else if ( columnName.EndsWith ( "Value" ) )
            {
                propertyInstance.Length ( ValueLength );
            }
        }
Example #16
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);
         }
     }
 }
Example #17
0
        public void Apply(IPropertyInstance instance)
        {
            instance.Not.Nullable();
            instance.Length(100);

            // # DateTime alanları veritabanına yazılırken milisaniye bilgisi kaybedildiği için bu çözüm uygulandı
            var propertyType = instance.Property.PropertyType;

            if (propertyType == typeof(DateTime) || propertyType == typeof(DateTime?))
            {
                instance.CustomType("Timestamp");
            }
        }
Example #18
0
        public void Apply(IPropertyInstance instance)
        {
            if (instance.Property.PropertyType == typeof(byte[]))
            {
                instance.
                CustomSqlType("varbinary(max)");

                instance.
                Length(Int32.MaxValue);

                instance.
                LazyLoad();
            }
        }
 public void Apply(IPropertyInstance propertyMapping)
 {
     try
     {
         if (propertyMapping.Type == typeof(byte[]))
         {
             propertyMapping.Length(int.MaxValue);
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e);
     }
 }
Example #20
0
 /// <summary>
 /// Sets Length based on type and name.
 /// </summary>
 /// <param name="instance">The instance.</param>
 public void Apply(IPropertyInstance instance)
 {
     if (!instance.Property.DeclaringType.IsNHibernateComponent())
     {
         if (instance.Property.PropertyType == typeof(string))
         {
             Apply(instance, instance.Name);
         }
         else if (instance.Property.PropertyType.IsEnum ||
                  instance.Property.PropertyType.IsNullableEnum())
         {
             instance.Length(EnumLength);
         }
     }
 }
        public void Apply(IPropertyInstance instance)
        {
            var meta = QueryFluentMetadata.FindMetadataFor(instance.EntityType, instance.Property.Name);
            if (meta != null)
            {
                if (meta.Required.HasValue && meta.Required.Value)
                {
                    instance.Not.Nullable();
                }

                var maxLength = meta.GetMaximumLength();
                if (maxLength.HasValue && maxLength.Value > 0)
                {
                    instance.Length(maxLength.Value);
                }
            }
        }
Example #22
0
        public void Apply(IPropertyInstance instance)
        {
            if (!instance.Property.MemberInfo.DeclaringType.IsNullable())
            {
                instance.Not.Nullable();
            }

            if (instance.Property.PropertyType == typeof(string))
            {
                instance.CustomType("AnsiString");
                instance.Length(100);
            }

            if (instance.Property.PropertyType == typeof(decimal))
            {
                instance.Precision(12);
                instance.Scale(2);
            }
        }
        public void Apply(IPropertyInstance instance)
        {

            if (instance.EntityType.Name == "AuditLog")
                instance.Length(10000);


            //if (instance.Name == "OriginalValue")
            //{
            //    instance.Length(10000);
            //}

            //if (instance.Name == "NewValue")
            //{
            //    instance.Length(10000);
            //}


        }
        public void Apply(IPropertyInstance instance)
        {
            var meta = QueryFluentMetadata.FindMetadataFor(instance.EntityType, instance.Property.Name);

            if (meta != null)
            {
                if (meta.Required.HasValue && meta.Required.Value)
                {
                    instance.Not.Nullable();
                }

                var maxLength = meta.GetMaximumLength();

                if (maxLength.HasValue && maxLength.Value > 0)
                {
                    instance.Length(maxLength.Value);
                }
            }
        }
Example #25
0
        /// <summary>
        /// Sets the length of the property based on the Name.
        /// </summary>
        /// <param name="propertyInstance">The property instance.</param>
        /// <param name="columnName">Name of the column.</param>
        public static void Apply(IPropertyInstance propertyInstance, string columnName)
        {
            var lengthAttributes = propertyInstance.Property.MemberInfo.GetCustomAttributes(
                typeof(ColumnLengthAttribute), false);

            if (lengthAttributes.Length > 0)
            {
                var columnLength = ( ColumnLengthAttribute )lengthAttributes[0];
                propertyInstance.Length(columnLength.Length);
            }
            else if (columnName.EndsWith("Code"))
            {
                propertyInstance.Length(CodeLength);
            }
            else if (columnName.EndsWith("Number"))
            {
                propertyInstance.Length(NumberLength);
            }
            else if (columnName.EndsWith("Name"))
            {
                propertyInstance.Length(NameLength);
            }
            else if (columnName.EndsWith("Note"))
            {
                propertyInstance.Length(NoteLength);
            }
            else if (columnName.EndsWith("Description"))
            {
                propertyInstance.Length(DescriptionLength);
            }
            else if (columnName.EndsWith("Identifier"))
            {
                propertyInstance.Length(IdentifierLength);
            }
            else if (columnName.EndsWith("Value"))
            {
                propertyInstance.Length(ValueLength);
            }
        }
Example #26
0
        public void Apply(IPropertyInstance instance)
        {
            if (instance.Property.PropertyType == typeof(byte[]))
            {
                instance.CustomType("BinaryBlob");
                instance.Length(1048576);
            }
            else
            {
                instance.CustomType(instance.Property.PropertyType);

                if (instance.Property.PropertyType.IsEnum)
                {
                    instance.Not.Nullable();
                }

                if (instance.Property.Name.Equals("Deleted"))
                {
                    instance.Not.Nullable();
                }
            }
        }
 public void Apply(IPropertyInstance instance)
 {
     instance.Length(short.MaxValue);
 }
 public void Apply(IPropertyInstance propertyMapping)
 {
     propertyMapping.Length(4000);
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.Length(int.MaxValue);
     //instance.CustomSqlType("varbinary(MAX)");
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.Length(255);
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.Length(2147483647);
     instance.CustomSqlType("varbinary(MAX)");
 }
 public void Apply(IPropertyInstance instance)
 {
     instance.Length(300);
     instance.Nullable();
 }
Example #33
0
 public void Apply(IPropertyInstance instance)
 {
     instance.Length(Enum.GetNames(instance.Property.PropertyType).Max(name => name.Length));
     instance.CustomType(typeof(string));
 }
		public void Apply(IPropertyInstance instance)
		{
			var attribute = instance.Property.MemberInfo.GetMemberAttribute<StringLengthAttribute>();
			var length = attribute != null ? attribute.MaximumLength : 4001; // Anything over 4000 equates to (max)
			instance.Length(length);
		}
 public void Apply(IPropertyInstance instance)
 {
     instance.Length(10000); // needed for sql server (tested with versions 2005, 2008, 2014)
 }
 /// <summary>
 /// Sets Length based on type and name.
 /// </summary>
 /// <param name="instance">The instance.</param>
 public void Apply( IPropertyInstance instance )
 {
     if ( ! instance.Property.DeclaringType.IsNHibernateComponent () )
     {
         if ( instance.Property.PropertyType == typeof( string ) )
         {
             Apply ( instance, instance.Name );
         }
         else if ( instance.Property.PropertyType.IsEnum ||
                   instance.Property.PropertyType.IsNullableEnum () )
         {
             instance.Length ( EnumLength );
         }
     }
 }
 public void Apply(IPropertyInstance instance)
 {
     if (instance.Name == "Name")
         instance.Length(255);
 }
Example #38
0
 public void Apply(IPropertyInstance target)
 {
     target.Length(20);
 }