Пример #1
0
        protected virtual Type GetSystemType(string dataType, string columnType, DataTypeInfo dataTypeInfo, int length, int precision, int scale)
        {
            var systemType = dataTypeInfo != null ? Type.GetType(dataTypeInfo.DataType) : null;

            if (length == 1 && !GenerateChar1AsString && systemType == typeof(string))
                systemType = typeof(char);

            return systemType;
        }
Пример #2
0
        protected virtual string GetDbType(string columnType, DataTypeInfo dataType, int length, int prec, int scale)
        {
            var dbType = columnType;

            if (dataType != null)
            {
                var format = dataType.CreateFormat;
                var parms  = dataType.CreateParameters;

                if (!string.IsNullOrWhiteSpace(format) && !string.IsNullOrWhiteSpace(parms))
                {
                    var paramNames  = parms.Split(',');
                    var paramValues = new object[paramNames.Length];

                    for (var i = 0; i < paramNames.Length; i++)
                    {
                        switch (paramNames[i].Trim().ToLower())
                        {
                            case "size"       :
                            case "length"     :
                            case "max length" : paramValues[i] = length; break;
                            case "precision"  : paramValues[i] = prec;   break;
                            case "scale"      : paramValues[i] = scale;  break;
                        }
                    }

                    if (paramValues.All(v => v != null && (int)v != 0))
                        dbType = format.Args(paramValues);
                }
            }

            return dbType;
        }