Ejemplo n.º 1
0
        object GetColumnSchemas(DbDataReader reader)
        {
            var table = reader.GetSchemaTable();

            if (table == null)
            {
                return(null);
            }
            var    result     = new List <ColumnSchema>();
            object autoColumn = null;

            foreach (DataRow row in table.Rows)
            {
                var info = new ColumnSchema(row);
                result.Add(info);
                if (info.IsAutoIncrement)
                {
                    autoColumn = info;
                }
            }
            ColumnSchemas = result.OrderBy(n => n.Index).ToList();
            return(autoColumn);
        }
Ejemplo n.º 2
0
        string ColumnScript(string name, PropertyInfo propertyInfo, KeyTypeStore keyStore, ColumnSchema schema, char comma)
        {
            var type            = Type.GetTypeCode(propertyInfo.PropertyType);
            var typeStatement   = dataTypes.ContainsKey(type) ? dataTypes[type] : dataTypes[TypeCode.String];
            var maxLen          = Reflector.GetCustomAttribute <MaxLengthAttribute>(propertyInfo);
            var maxLenStatement = maxLen != null ? $" ({maxLen.Length})" : string.Empty;
            var required        = Reflector.GetCustomAttribute <RequiredAttribute>(propertyInfo);
            var primaryKey      = !keyStore.Keys.Exists(propertyInfo.Name) ? string.Empty : PrimaryKey;

            return($"[{name}] {typeStatement}{maxLenStatement}{(required == null ? string.Empty : NotNull)}{primaryKey}{comma}");
        }