public override DbObjectCollection CreateCollection(IConnectionInformation info) { var collection = new DbObjectCollection(info); var con = collection.Context.Database.Connection; if (con.State != System.Data.ConnectionState.Open) { con.Open(); } collection.DataTypes = new Dictionary <string, DbObjectCollection.DataType>(); foreach (DataRow row in GetDataTypes().Rows) { var dt = new DbObjectCollection.DataType(row); collection.DataTypes.Add(dt.Name, dt); } collection.RegisterObjects(con.GetSchema("Tables"), true, "TABLE_SCHEMA NOT IN('information_schema','pg_catalog')"); collection.RegisterObjects(con.GetSchema("Views"), false, "TABLE_SCHEMA NOT IN('information_schema','pg_catalog')"); var creator = new DbObjectCollection.ColumnCreator(); collection.RegisterMembers(con.GetSchema("Columns"), creator); collection.RegisterPrimaryKey(); return(collection); }
public override ColumnElement CreateColumnForDefault(DataRow row, string name, DbObjectCollection.DataType type) { ColumnElement column = column = base.CreateColumnForDefault(row, name, type); if (!row.IsNull("PRIMARY_KEY")) { if (row.Field <bool>("PRIMARY_KEY")) { column.IsKey = true; column.ColumnIndex = Convert.ToInt32(row["ORDINAL_POSITION"]); } } return(column); }
public override ColumnElement CreateColumnForDefault(DataRow row, string name, DbObjectCollection.DataType type) { ColumnElement column = column = base.CreateColumnForDefault(row, name, type); if (!row.IsNull("EXTRA") && row.Field <string>("EXTRA") == "auto_increment") { column.Identity = new IdentityInfo(); } if (!row.IsNull("COLUMN_KEY")) { if (row.Field <string>("COLUMN_KEY") == "PRI") { column.IsKey = true; column.ColumnIndex = Convert.ToInt32(row["ORDINAL_POSITION"]); } } return(column); }