Exemplo n.º 1
0
        // Public Methods (11) 

        public static object Create(SqlRequest sqlRequest, SqlConnection connection, SqlTransaction transaction)
        {
            if (sqlRequest == null)
            {
                throw new DuradosException("sqlRequest is empty");
            }

            object     returnedValue = null;
            SqlCommand command       = new SqlCommand(sqlRequest.Sql, connection);

            if (transaction != null)
            {
                command.Transaction = transaction;
            }

            if (sqlRequest.Parameters != null)
            {
                command.Parameters.AddRange(sqlRequest.Parameters.ToArray());
            }

            returnedValue = command.ExecuteScalar();
            command.Parameters.Clear();

            return(returnedValue);
        }
Exemplo n.º 2
0
        public static object Create(Dictionary <string, object> values, string tableName, IList <string> encryptedcolumnNamesList, bool autoIdentity, SqlConnection connection, SqlTransaction transaction)
        {
            string sql = GetSqlInsertStatement(values.Keys.ToList(), tableName, autoIdentity, encryptedcolumnNamesList);
            IList <SqlParameter> parameters = GetParemeters(values);
            SqlRequest           sqlRequest = GetInsertSqlRequest(values, tableName, encryptedcolumnNamesList, autoIdentity);

            return(Create(sqlRequest, connection, transaction));
        }
Exemplo n.º 3
0
        public static void Update(Dictionary <string, object> values, string tableName, string whereStatement, SqlConnection connection, SqlTransaction transaction)
        {
            string sql = SqlGeneralAccess.GetSqlUpdateStatement(values.Keys.ToList(), tableName, whereStatement);
            IList <SqlParameter> parameters = SqlGeneralAccess.GetParemeters(values);

            SqlRequest sqlRequest = new SqlRequest(sql, parameters);

            Update(sqlRequest, connection, transaction);
        }
Exemplo n.º 4
0
 public static void Delete(string tableName, string whereStatement, string connectionString)
 {
     using (SqlConnection connection = new SqlConnection(connectionString))
     {
         string sql = "delete from [{0}] where {1}";
         sql = string.Format(sql, tableName, whereStatement);
         SqlRequest requst = new SqlRequest(sql, null);
         connection.Open();
         ExecuteNonQuery(requst, connection, null);
     }
 }
Exemplo n.º 5
0
        public static void ExecuteNonQuery(SqlRequest sqlRequest, SqlConnection connection, SqlTransaction transaction)
        {
            SqlCommand command = new SqlCommand(sqlRequest.Sql, connection);

            if (transaction != null)
            {
                command.Transaction = transaction;
            }

            if (sqlRequest.Parameters != null)
            {
                command.Parameters.AddRange(sqlRequest.Parameters.ToArray());
            }

            command.ExecuteNonQuery();
            command.Parameters.Clear();
        }
Exemplo n.º 6
0
 public static void Update(SqlRequest sqlRequest, SqlConnection connection, SqlTransaction transaction)
 {
     ExecuteNonQuery(sqlRequest, connection, transaction);
 }