Пример #1
0
        public void SetUp(DataSet dataSource)
        {
            if (dataSource is NorthwindDataSet)
            {
                Assert.Ignore("Northwind is buggy... because import in VC# is buggy");
            }
            this.Admin.CreateDatabase();

            dataSource.EnforceConstraints = true;
            this.graph = DataGraph.Create(dataSource);

            this.pop = new DatabasePopulator();
            this.pop.Populate(dataSource);

            // add one row data per table
            foreach (DataTable table in this.graph.GetSortedTables())
            {
                ITablePopulator tp = this.pop.Tables[table];
                tp.Generate();
                table.Rows.Add(tp.Row);
                table.AcceptChanges();
            }

            this.gen = new SqlGenerator(
                this.ConnectionString,
                this.DatabaseName,
                dataSource
                );
        }
Пример #2
0
        internal void PopulateForeignKeys()
        {
            foreach (Constraint constraint in this.Table.Constraints)
            {
                ForeignKeyConstraint fk = constraint as ForeignKeyConstraint;
                if (fk == null)
                {
                    continue;
                }

                ITablePopulator foreignTable = null;
                if (fk.RelatedTable == this.Table)
                {
                    foreignTable = this;
                }
                else
                {
                    foreignTable = this.database.Tables[fk.RelatedTable];
                }

                // create and add
                IForeignKeyProvider fkp = new ForeignKeyProvider(foreignTable, fk);
                this.foreignKeys.Add(fkp);
            }
        }
Пример #3
0
 public ForeignKeyProviderCollection(ITablePopulator tablePopulator)
 {
     if (tablePopulator == null)
     {
         throw new ArgumentNullException("tablePopulator");
     }
     this.tablePopulator = new WeakReference(tablePopulator);
 }
Пример #4
0
 public SqlCommandUniqueValidator(
     ITablePopulator table,
     UniqueConstraint unique,
     string connectionString
     )
     : base(table, unique, new SqlFactory(), connectionString)
 {
 }
Пример #5
0
        public void AddProduct()
        {
            ITablePopulator products = this.pop.Tables[this.db.Products];

            this.db.Products.Rows.Add(products.Generate());
            Console.WriteLine("AddProduct");
            this.Check();
        }
Пример #6
0
        public void AddOrder()
        {
            ITablePopulator orders = this.pop.Tables[this.db.Orders];

            this.db.Orders.Rows.Add(orders.Generate());
            Console.WriteLine("AddOrder");
            this.Check();
        }
Пример #7
0
 public void Remove(ITablePopulator tablePopulator)
 {
     if (tablePopulator == null)
     {
         throw new ArgumentNullException("tablePopulator");
     }
     this.Remove(tablePopulator.Table);
 }
Пример #8
0
 public UniqueValidatorCollection(ITablePopulator tablePopulator)
 {
     if (tablePopulator == null)
     {
         throw new ArgumentNullException("tablePopulator");
     }
     this.tablePopulator = new WeakReference(tablePopulator);
 }
Пример #9
0
 public void Add(ITablePopulator tablePopulator)
 {
     if (tablePopulator == null)
     {
         throw new ArgumentNullException("tablePopulator");
     }
     this.tablePopulators.Add(tablePopulator.Table.TableName, tablePopulator);
 }
Пример #10
0
 public bool Contains(ITablePopulator tablePopulator)
 {
     if (tablePopulator == null)
     {
         throw new ArgumentNullException("tablePopulator");
     }
     return(this.Contains(tablePopulator.Table));
 }
 public SqlCommandUniqueValidator(
     ITablePopulator table,
     UniqueConstraint unique,
     string connectionString
     )
     : base(table,unique,new SqlFactory(),connectionString)
 {
 }
 public UniqueValidatorBase(ITablePopulator table, UniqueConstraint unique)
 {
     if(table==null)
         throw new ArgumentNullException("table");
     if(unique==null)
         throw new ArgumentNullException("unique");
     this.table=new WeakReference(table);
     this.unique=unique;
 }
Пример #13
0
        public void SetUp()
        {
            this.db  = new UserOrderProductDataSet();
            this.pop = new DatabasePopulator();
            this.pop.Populate(this.db);

            this.users         = this.pop.Tables[this.db.Tables["Users"]];
            this.orders        = this.pop.Tables[this.db.Tables["Orders"]];
            this.products      = this.pop.Tables[this.db.Tables["Products"]];
            this.orderProducts = this.pop.Tables[this.db.Tables["OrderProducts"]];
        }
Пример #14
0
 public UniqueValidatorBase(ITablePopulator table, UniqueConstraint unique)
 {
     if (table == null)
     {
         throw new ArgumentNullException("table");
     }
     if (unique == null)
     {
         throw new ArgumentNullException("unique");
     }
     this.table  = new WeakReference(table);
     this.unique = unique;
 }
 public DbCommandUniqueValidatorBase(
     ITablePopulator table,
     UniqueConstraint unique,
     IDbFactory dbFactory,
     string connectionString
     )
     : base(table,unique)
 {
     if (dbFactory == null)
         throw new ArgumentNullException("factory");
     if (connectionString == null)
         throw new ArgumentNullException("connectionString");
     this.dbFactory = dbFactory;
     this.connectionString = connectionString;
 }
Пример #16
0
 public DbCommandUniqueValidatorBase(
     ITablePopulator table,
     UniqueConstraint unique,
     IDbFactory dbFactory,
     string connectionString
     )
     : base(table, unique)
 {
     if (dbFactory == null)
     {
         throw new ArgumentNullException("factory");
     }
     if (connectionString == null)
     {
         throw new ArgumentNullException("connectionString");
     }
     this.dbFactory        = dbFactory;
     this.connectionString = connectionString;
 }
        public ForeignKeyProviderBase(ITablePopulator foreignTable, ForeignKeyConstraint foreignKey)
        {
            if (foreignTable == null)
                throw new ArgumentNullException("foreignTable");
            if (foreignKey == null)
                throw new ArgumentNullException("foreignKey");
            this.foreignTable = foreignTable;
            this.foreignKey = foreignKey;

            isNullable = true;
            foreach (DataColumn column in foreignKey.Columns)
            {
                if (!column.AllowDBNull)
                {
                    isNullable = false;
                    break;
                }
            }
        }
Пример #18
0
        public ForeignKeyProviderBase(ITablePopulator foreignTable, ForeignKeyConstraint foreignKey)
        {
            if (foreignTable == null)
            {
                throw new ArgumentNullException("foreignTable");
            }
            if (foreignKey == null)
            {
                throw new ArgumentNullException("foreignKey");
            }
            this.foreignTable = foreignTable;
            this.foreignKey   = foreignKey;

            isNullable = true;
            foreach (DataColumn column in foreignKey.Columns)
            {
                if (!column.AllowDBNull)
                {
                    isNullable = false;
                    break;
                }
            }
        }
Пример #19
0
 public MethodUniqueValidator(ITablePopulator table, UniqueConstraint unique, MethodInfo method)
     : base(table, unique)
 {
     this.method = method;
 }
 public UniqueValidatorCollection(ITablePopulator tablePopulator)
 {
     if (tablePopulator==null)
         throw new ArgumentNullException("tablePopulator");
     this.tablePopulator=new WeakReference(tablePopulator);
 }
 public DictionaryUniqueValidator(ITablePopulator table, UniqueConstraint unique)
     : base(table,unique)
 {
 }
 public ForeignKeyProvider(ITablePopulator foreignTable, ForeignKeyConstraint foreignKey)
     : base(foreignTable,foreignKey)
 {
 }
        public void SetUp()
        {
            this.db = new UserOrderProductDataSet();
            this.pop = new DatabasePopulator();
            this.pop.Populate(this.db);

            this.users=this.pop.Tables[this.db.Tables["Users"]];
            this.orders=this.pop.Tables[this.db.Tables["Orders"]];
            this.products=this.pop.Tables[this.db.Tables["Products"]];
            this.orderProducts=this.pop.Tables[this.db.Tables["OrderProducts"]];
        }
 public ForeignKeyProviderCollection(ITablePopulator tablePopulator)
 {
     if (tablePopulator==null)
         throw new ArgumentNullException("tablePopulator");
     this.tablePopulator=new WeakReference(tablePopulator);
 }
Пример #25
0
 public ForeignKeyProvider(ITablePopulator foreignTable, ForeignKeyConstraint foreignKey)
     : base(foreignTable, foreignKey)
 {
 }
Пример #26
0
 public DictionaryUniqueValidator(ITablePopulator table, UniqueConstraint unique)
     : base(table, unique)
 {
 }