예제 #1
0
        /// <summary>
        /// 创建数据库操作对象
        /// </summary>
        /// <param name="connectInfo">数据库连接信息</param>
        /// <returns></returns>
        public static BaseDbActionService DbServerFactory(ConnectInfo connectInfo)
        {
            BaseDbActionService service = null;

            switch (connectInfo.BaseType)
            {
            case DataBaseType.SQL_LITER:
                service = new SQLiterDbAction(connectInfo);
                break;

            case DataBaseType.SQL_MY_SQL:
                service = new MySqlDbAction(connectInfo);
                break;

            case DataBaseType.SQL_ORACLE:
                service = new OracleSqlDbAction(connectInfo);
                break;

            default:
                service = new ServerDbAction(connectInfo);
                break;
            }

            return(service);
        }
예제 #2
0
        public static void CreateTable(Dictionary <string, object> tableInfo)
        {
            string str;
            BaseDbActionService service = DbAction.CurrentDB();;

            SQLHelper helper;

            str = ResolveCreateTableSql(tableInfo);

            try
            {
                helper = new SQLHelper(str, Array.Empty <object>());
                service.ExecuteNonQuery(helper);
            }
            catch (Exception e)
            {
                throw new Exception("数据表创建失败:执行语句\n" + str, e);
            }
            finally
            {
                service.Dispose();
            }



            return;
        }
예제 #3
0
        public static BaseDbActionService CreateNewDbAction(ConnectInfo connectInfo)
        {
            if (db == null)
            {
                lock (lockeObject) {
                    if (db == null)
                    {
                        db = new DbAction();
                    }
                }
            }
            BaseDbActionService service = db.GetDbConnection(connectInfo);

            return(service);
        }