ExecuteSql() публичный Метод

public ExecuteSql ( string call ) : int
call string
Результат int
Пример #1
0
 private void ExecuteSqls(string[] sqls)
 {
     foreach (string sql in sqls)
     {
         Database.ExecuteSql(sql);
     }
 }
Пример #2
0
        public virtual void AddForeignKey(string fkName, string table, string column, string referencingTable,
                                          string referencingColumn, OnDelete onDelete)
        {
            string sql = Dialect.GetForeignKeySql(fkName, table, column, referencingTable, referencingColumn, onDelete);

            Database.ExecuteSql(sql);
        }
Пример #3
0
 public virtual void RemoveColumn(string tableName, string columnName)
 {
     string[] sqls = Dialect.GetDropColumnSql(tableName, columnName);
     for (int i = 0; i < sqls.Length; i++)
     {
         Database.ExecuteSql(sqls[i]);
     }
 }
Пример #4
0
        public virtual int InsertSql(string table, string[] columns, object[] values)
        {
            if (values == null)
            {
                values = new object[columns.Length];
            }
            string sql = Dialect.GetInsertSql(table, columns, values);

            return(Database.ExecuteSql(sql, Dialect.ConvertToNamedParameters(values)));
        }
Пример #5
0
        public virtual int DeleteSql(string table, Filter filter)
        {
            string sql = Dialect.GetDeleteSql(table);

            if (filter != null)
            {
                string   whereSql   = Dialect.GetWhereSql(filter, 0);
                object[] pars       = filter.GetAllValueParameters();
                In[]     parameters = Dialect.ConvertToNamedParameters(0, pars);
                return(Database.ExecuteSql(sql + " " + whereSql, parameters));
            }

            return(Database.ExecuteSql(sql));
        }
Пример #6
0
        public virtual object InsertReturningSql(string table, string columnToReturn, string[] columns, object[] values)
        {
            var returningPar = new Out {
                Name = "returning_" + columnToReturn, Size = 4000
            };
            string retSql = Dialect.GetInsertReturningColumnSql(table, columns, values, columnToReturn, returningPar.Name);

            object[]      pars     = Dialect.ConvertToNamedParameters(values);
            List <object> listPars = pars.ToList();

            listPars.Add(returningPar);
            Database.ExecuteSql(retSql, listPars.ToArray());
            return(returningPar.Value);
        }
Пример #7
0
        public virtual int UpdateSql(string table, string[] columns, object[] values, Filter filter)
        {
            if (values == null)
            {
                values = new object[columns.Length];
            }
            string sql = Dialect.GetUpdateSql(table, columns, values);

            In[] parameters = Dialect.ConvertToNamedParameters(values);
            if (filter != null)
            {
                string   whereSql         = Dialect.GetWhereSql(filter, parameters.Count());
                object[] pars             = filter.GetAllValueParameters();
                In[]     filterParameters = Dialect.ConvertToNamedParameters(parameters.Count(), pars);
                filterParameters = filterParameters.Where(x => x.Value != null && x.Value != DBNull.Value).ToArray();
                parameters       = parameters.Concat(filterParameters).ToArray();
                sql = sql + " " + whereSql;
            }

            return(Database.ExecuteSql(sql, parameters));
        }
Пример #8
0
        public void AddColumnComment(string tableName, string columnName, string comment)
        {
            string sql = Dialect.GetAddCommentToColumnSql(tableName, columnName, comment);

            Database.ExecuteSql(sql);
        }
Пример #9
0
 public void ModifyColumn(string tableName, string columnName, Column columnDefinition)
 {
     Database.ExecuteSql(Dialect.GetModifyColumnSql(tableName, columnName, columnDefinition));
 }
Пример #10
0
        public virtual void RemoveForeignKey(string foreigKeyName, string tableName)
        {
            string sql = Dialect.GetDropForeignKeySql(foreigKeyName, tableName);

            Database.ExecuteSql(sql);
        }
Пример #11
0
        public void RenameTable(string tableName, string newTableName)
        {
            string sql = Dialect.GetRenameTableSql(tableName, newTableName);

            Database.ExecuteSql(sql);
        }
Пример #12
0
        public void RenameColumn(string tableName, string columnName, string newColumnName)
        {
            string sql = Dialect.GetRenameColumnSql(tableName, columnName, newColumnName);

            Database.ExecuteSql(sql);
        }
Пример #13
0
        public void RemovePrimaryKey(string tableName, string primaryKeyName)
        {
            string sql = Dialect.GetDropPrimaryKeySql(tableName, primaryKeyName);

            Database.ExecuteSql(sql);
        }
Пример #14
0
        public virtual void RemoveColumnComment(string tableName, string columnName)
        {
            string sql = Dialect.GetRemoveCommentFromColumnSql(tableName, columnName);

            Database.ExecuteSql(sql);
        }
Пример #15
0
        public virtual void AddUniqueKey(string uniqueKeyName, string tableName, params string[] columnNames)
        {
            string sql = Dialect.GetUniqueKeySql(uniqueKeyName, tableName, columnNames);

            Database.ExecuteSql(sql);
        }
Пример #16
0
        public virtual void RemoveUniqueKey(string uniqueKeyName, string tableName)
        {
            string sql = Dialect.GetDropUniqueKeySql(uniqueKeyName, tableName);

            Database.ExecuteSql(sql);
        }
Пример #17
0
        public virtual void AddColumn(string tableName, Column column)
        {
            string sql = Dialect.GetAddColumnSql(tableName, column);

            Database.ExecuteSql(sql);
        }
Пример #18
0
        public virtual void RemoveIndex(string indexName, string table)
        {
            string sql = Dialect.GetDropIndexSql(indexName, table);

            Database.ExecuteSql(sql);
        }
Пример #19
0
        public virtual void AddIndex(string indexName, string tableName, params string[] columnNames)
        {
            string sql = Dialect.GetCreateIndexSql(indexName, tableName, columnNames);

            Database.ExecuteSql(sql);
        }
Пример #20
0
        public virtual void AddNamedPrimaryKey(string tableName, string pkName, params string[] columnNames)
        {
            string sql = Dialect.GetPrimaryKeySql(tableName, pkName, columnNames);

            Database.ExecuteSql(sql);
        }
Пример #21
0
        public virtual void RemoveTableComment(string tableName)
        {
            string sql = Dialect.GetRemoveCommentFromTableSql(tableName);

            Database.ExecuteSql(sql);
        }