示例#1
0
        /// <summary>
        /// Create table in the database.
        /// </summary>
        /// <param name="sqls"></param>
        /// <param name="ctx"></param>
        /// <param name="currentModel"></param>
        public virtual void ExecuteSqlInDb(List <string> sqls, ModelContext ctx, Model currentModel)
        {
            DbCreateType createType = ctx.AllModels.Settings.DbAction_Create;
            DBSchema     helper     = new DBSchema(_conn);
            string       error      = "Error executing sql for model : " + currentModel.Name + " table name : " + currentModel.TableName;

            Try.CatchLog(error, () =>
            {
                foreach (string sql in sqls)
                {
                    helper.ExecuteNonQuery(sql, CommandType.Text, null);
                }
            });
        }
示例#2
0
        /// <summary>
        /// Create table in the database.
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="ctx"></param>
        /// <param name="currentModel"></param>
        public virtual void ExecuteSqlProcsInDb(BoolMessageItem <List <string> > procs, ModelContext ctx, Model currentModel)
        {
            DbCreateType createType = ctx.AllModels.Settings.DbAction_Create;
            DBSchema     helper     = new DBSchema(_conn);

            try
            {
                foreach (string sql in procs.Item)
                {
                    helper.ExecuteNonQuery(sql, CommandType.Text, null);
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Error creating tables for model : " + currentModel.Name + " table name : " + currentModel.TableName);
                Logger.Error(ex.Message);
            }
        }
示例#3
0
        /// <summary>
        /// Create table in the database.
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="ctx"></param>
        /// <param name="currentModel"></param>
        public virtual void ExecuteSqlInDb(string sql, ModelContext ctx, Model currentModel)
        {
            DbCreateType createType = ctx.AllModels.Settings.DbAction_Create;
            DBSchema     helper     = new DBSchema(_conn);

            try
            {
                if (createType == DbCreateType.DropCreate)
                {
                    helper.DropTable(currentModel.TableName);
                }
                helper.ExecuteNonQuery(sql, CommandType.Text, null);
            }
            catch (Exception ex)
            {
                Logger.Error("Error creating tables for model : " + currentModel.Name + " table name : " + currentModel.TableName);
                Logger.Error(ex.Message);
            }
        }