Example #1
0
        internal string GetCollate(SqlDbTypeAttribute att)
        {
            if (att != null && att.Collation != null)
            {
                return(att.Collation);
            }

            return(null);
        }
Example #2
0
        internal SqlDbTypePair GetSqlDbType(SqlDbTypeAttribute att, Type type)
        {
            if (att != null && att.HasSqlDbType)
            {
                return(new SqlDbTypePair(att.SqlDbType, att.UserDefinedTypeName));
            }

            return(GetSqlDbTypePair(type.UnNullify()));
        }
Example #3
0
        internal int?GetSqlScale(SqlDbTypeAttribute att, SqlDbType sqlDbType)
        {
            if (att != null && att.HasScale)
            {
                return(att.Scale);
            }

            return(defaultScale.TryGetS(sqlDbType));
        }
Example #4
0
        internal int?GetSqlScale(SqlDbTypeAttribute att, SqlDbType sqlDbType)
        {
            if (att != null && att.HasScale)
            {
                if (sqlDbType != SqlDbType.Decimal)
                {
                    throw  new InvalidOperationException($"{sqlDbType} can not have Scale");
                }

                return(att.Scale);
            }

            return(defaultScale.TryGetS(sqlDbType));
        }
Example #5
0
        internal int?GetSqlSize(SqlDbTypeAttribute att, PropertyRoute route, SqlDbType sqlDbType)
        {
            if (att != null && att.HasSize)
            {
                return(att.Size);
            }

            if (route != null && route.Type == typeof(string))
            {
                var sla = ValidatorAttribute <StringLengthValidatorAttribute>(route);
                if (sla != null)
                {
                    return(sla.Max == -1 ? int.MaxValue : sla.Max);
                }
            }

            return(defaultSize.TryGetS(sqlDbType));
        }