Exemple #1
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);
            }
        }