private bool ExecuteCreateTable(TestExecutePattern pattern, DataEngine db, string tableName, object controller)
        {
            int result          = 0;
            DbCommandBuilder cb = GetTableBuilder(tableName);

            Debug.WriteLine("");
            if (pattern == TestExecutePattern.InTransaction)
            {
                Debug.WriteLine("在事务中执行!");
                DBTransactionController trans = (DBTransactionController)controller;
                Debug.WriteLine(cb.Parsing(db.CommandParserAdapter));
                Debug.WriteLine("执行结果:");
                if (trans.DBA.TableExists(tableName))
                {
                    Debug.Write(string.Format("创建失败,表名 {0} 在数据库中已存在!", tableName));
                    return(false);
                }
                else
                {
                    result = trans.DBA.ExecuteNoneQuery(cb); // execute create table.
                    if (result != -1)
                    {
                        Debug.Write(string.Format("成功创建表 {0} !", tableName));
                        return(true);
                    }
                    else
                    {
                        Debug.Write(trans.DBA.Errors.LastOrDefault().Message);
                        return(false);
                    }
                }
            }
            else
            {
                Debug.WriteLine("批量处理器执行!");
                BatchCommander batch = (BatchCommander)controller;
                Debug.WriteLine(cb.Parsing(db.CommandParserAdapter));
                Debug.WriteLine("执行结果:");
                if (batch.TableExists(tableName))
                {
                    Debug.Write(string.Format("表名 {0} 在数据库中已存在!", tableName));
                    return(false);
                }
                else
                {
                    result = batch.ExecuteNonQuery(cb); // execute create table.
                    if (result != -1)
                    {
                        Debug.Write(string.Format("成功创建表 {0} !", tableName));
                        return(true);
                    }
                    else
                    {
                        Debug.Write(string.Format("表 {0} 创建失败!", tableName));
                        return(false);
                    }
                }
            }
        }
 private void ExecuteDrop(DataEngine db)
 {
     using (BatchCommander batch = new BatchCommander(db))
     {
         ExecuteDrop(batch, table_products);
         ExecuteDrop(batch, table_categories);
     }
 }
 /// <summary>
 /// 释放对象所占用的资源.
 /// </summary>
 /// <param name="disposing">手动调用则为 true,由对象终结器调用时则为 false .</param>
 private void Dispose(bool disposing)
 {
     if (_commander != null)
     {
         _commander.Dispose();
     }
     _commander = null;
 }
 private void ExecuteDrop(BatchCommander batch, string tableName)
 {
     if (batch.TableExists(tableName))
     {
         try
         {
             batch.DropTable(tableName);
             Debug.WriteLine(string.Format("已成功删除表 {0} !", tableName));
         }
         catch (Exception Ex)
         {
             Debug.WriteLine(Ex.Message);
         }
     }
     else
     {
         Debug.WriteLine(string.Format("表 {0} 不存在,未执行删除操作!", tableName));
     }
 }
 /// <summary>
 /// 创建一个 <see cref="DataBatchProcessor"/> 的对象实例.
 /// </summary>
 /// <param name="_engine">此批处理使用的数据库引擎实例.</param>
 internal DataBatchProcessor(DataEngine _engine)
 {
     Engine     = _engine;
     _commander = new BatchCommander(_engine);
 }