Ejemplo n.º 1
0
 public static DataTable GetFunctions(DbConnection connection)
 {
     return((DataTable)XmlObjectSerializer.GetObject(Properties.Resources.StoreSchemaDefinition_Functions, typeof(DataTable)));
 }
Ejemplo n.º 2
0
        public static DataTable GetConstraints(OleDbConnection connection)
        {
            DataTable dataTable = (DataTable)XmlObjectSerializer.GetObject(Properties.Resources.StoreSchemaDefinition_Constraints, typeof(DataTable));

            DataTable schemaTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Check_Constraints, new object[] { });

            foreach (System.Data.DataRow table in schemaTable.Rows)
            {
                dataTable.Rows.Add(
                    table["CONSTRAINT_NAME"], // Id
                    DBNull.Value,             // ParentId
                    table["CONSTRAINT_NAME"], // Name
                    "CHECK",                  // ConstraintType
                    false,                    // IsDeferrable
                    false                     // IsIntiallyDeferred
                    );
            }

            schemaTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Foreign_Keys, new object[] { });

            foreach (System.Data.DataRow table in schemaTable.Rows)
            {
                if (Convert.ToInt32(table["ORDINAL"]) == 1)
                {
                    dataTable.Rows.Add(
                        table["FK_NAME"],       // Id
                        table["PK_TABLE_NAME"], // ParentId
                        table["FK_NAME"],       // Name
                        "FOREIGN KEY",          // ConstraintType
                        table["DEFERRABILITY"], // IsDeferrable
                        false                   // IsIntiallyDeferred
                        );
                }
            }

            schemaTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, new object[] { });

            foreach (System.Data.DataRow table in schemaTable.Rows)
            {
                if (Convert.ToInt32(table["ORDINAL"]) == 1)
                {
                    dataTable.Rows.Add(
                        table["TABLE_NAME"] + "." + table["PK_NAME"], // Id
                        table["TABLE_NAME"],                          // ParentId
                        table["PK_NAME"],                             // Name
                        "PRIMARY KEY",                                // ConstraintType
                        false,                                        // IsDeferrable
                        false                                         // IsIntiallyDeferred
                        );
                }
            }

            schemaTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Indexes, new object[] { });

            foreach (System.Data.DataRow table in schemaTable.Rows)
            {
                if (
                    Convert.ToInt32(table["ORDINAL_POSITION"]) == 1 &&  // Only the first field of the index
                    Convert.ToBoolean(table["PRIMARY_KEY"]) == false && // Not a primary key
                    Convert.ToBoolean(table["UNIQUE"]) == true          // Unique constraint
                    )
                {
                    dataTable.Rows.Add(
                        (string)table["TABLE_NAME"] + "." + (string)table["INDEX_NAME"], // Id
                        table["TABLE_NAME"],                                             // ParentId
                        table["INDEX_NAME"],                                             // Name
                        "UNIQUE",                                                        // ConstraintType
                        false,                                                           // IsDeferrable
                        false                                                            // IsIntiallyDeferred
                        );
                }
            }

            dataTable.AcceptChanges();

            return(dataTable);
        }
Ejemplo n.º 3
0
 public static DataTable GetProcedures(OleDbConnection oleDbConnection)
 {
     return((DataTable)XmlObjectSerializer.GetObject(Properties.Resources.StoreSchemaDefinition_Procedures, typeof(DataTable)));
 }
Ejemplo n.º 4
0
 public static DataTable GetViewConstraints(OleDbConnection connection)
 {
     return((DataTable)XmlObjectSerializer.GetObject(Properties.Resources.StoreSchemaDefinition_ViewConstraints, typeof(DataTable)));
 }