Пример #1
0
        static void Setup(DBTable refTable, DBTable mainTable)
        {
            var dbColumns = new List <DBColumn>();
            var dbColumn  = new DBColumn {
                Name = "Oid2"
            };

            dbColumns.Add(dbColumn);
            dbColumns.Add(mainTable.GetColumn("Oid"));
            mainTable.PrimaryKey = new DBPrimaryKey(dbColumns);
            mainTable.Columns.Add(dbColumn);
            mainTable.AddForeignKey(new DBForeignKey(dbColumns, refTable.Name, new StringCollection {
                "Oid", "Oid2"
            }));
        }
Пример #2
0
        private void FillForeignKey(DBTable table)
        {
            SqlDataReader rdfk = SqlHelper.ExecuteReader(new SqlConnection(this.ConnStr), CommandType.Text, string.Format(format_getAllForeignKeyByTable, table.TableName), null);

            while (rdfk.Read())
            {
                string columnName    = rdfk["columnName"].ToString();
                string refTableName  = rdfk["refTableName"].ToString();
                string refColumnName = rdfk["refColumnName"].ToString();

                DBColumn column = table.Columns.Where(row => row.ColumnName == columnName).FirstOrDefault();
                table.AddForeignKey(column, refTableName, refColumnName);
            }
            rdfk.Close();
            rdfk.Dispose();
        }
Пример #3
0
        protected virtual void FillForeignKey(DBTable table)
        {
            OleDbDataReader rdfk = OleDbHelper.ExecuteReader(this.OleDbConnStr, string.Format(this.Format_GET_ALL_ForeignKeys, table.TableName));

            while (rdfk.Read())
            {
                string columnName    = rdfk["columnName"].ToString();
                string refTableName  = rdfk["refTableName"].ToString();
                string refColumnName = rdfk["refColumnName"].ToString();

                DBColumn column = table.Columns.Where(row => row.ColumnName == columnName).FirstOrDefault();
                table.AddForeignKey(column, refTableName, refColumnName);
            }
            rdfk.Close();
            rdfk.Dispose();
        }
        static IDictionary <string, DBTable> CreateSchema(IDataStore dataStore)
        {
            DBTable customer = CreateTable("Customer");

            customer.AddColumn(new DBColumn("FirstName", false, null, SizeAttribute.DefaultStringMappingFieldSize, DBColumnType.String));
            customer.AddColumn(new DBColumn("LastName", false, null, SizeAttribute.DefaultStringMappingFieldSize, DBColumnType.String));
            DBTable order = CreateTable("Order");

            order.AddColumn(new DBColumn("ProductName", false, null, 200, DBColumnType.String));
            order.AddColumn(new DBColumn("OrderDate", false, null, 0, DBColumnType.DateTime));
            order.AddColumn(new DBColumn("Freight", false, null, 0, DBColumnType.Decimal));
            order.AddColumn(new DBColumn("Customer", false, null, 0, DBColumnType.Int32));
            order.AddForeignKey(new DBForeignKey(new StringCollection()
            {
                "Customer"
            }, "Customer", new StringCollection()
            {
                "OID"
            }));
            DBTable objectType = new DBTable("XPObjectType");

            objectType.AddColumn(new DBColumn("OID", true, null, 0, DBColumnType.Int32)
            {
                IsIdentity = true
            });
            objectType.AddColumn(new DBColumn("TypeName", false, null, 254, DBColumnType.String));
            objectType.AddColumn(new DBColumn("AssemblyName", false, null, 154, DBColumnType.String));
            objectType.AddIndex(new DBIndex(new StringCollection()
            {
                "TypeName"
            }, true));
            objectType.PrimaryKey = new DBPrimaryKey(new StringCollection()
            {
                "OID"
            });
            dataStore.UpdateSchema(false, customer, order, objectType);
            return(new Dictionary <string, DBTable>()
            {
                { "Customer", customer },
                { "Order", order }
            });
        }
Пример #5
0
 static void Setup(DBTable refTable, DBTable mainTable) {
     var dbColumns = new List<DBColumn>();
     var dbColumn = new DBColumn { Name = "Oid2" };
     dbColumns.Add(dbColumn);
     dbColumns.Add(mainTable.GetColumn("Oid"));
     mainTable.PrimaryKey = new DBPrimaryKey(dbColumns);
     mainTable.Columns.Add(dbColumn);
     mainTable.AddForeignKey(new DBForeignKey(dbColumns, refTable.Name, new StringCollection { "Oid", "Oid2" }));
 }