public List <Dictionary <string, object> > ExecuteQueryProcedure(SqlOperationGeneric sqlOperation) { var lstResult = new List <Dictionary <string, object> >(); using (var conn = new SqlConnection(CONNECTION_STRING)) using (var command = new SqlCommand(sqlOperation.ProcedureName, conn) { CommandType = CommandType.StoredProcedure }) { foreach (var param in sqlOperation.Parameters) { command.Parameters.Add(param); } conn.Open(); var reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { var dict = new Dictionary <string, object>(); for (var lp = 0; lp < reader.FieldCount; lp++) { dict.Add(reader.GetName(lp), reader.GetValue(lp)); } lstResult.Add(dict); } } } return(lstResult); }
internal void ExecuteProcedure(SqlOperationGeneric sqlOperation) { using (var conn = new SqlConnection(CONNECTION_STRING)) using (var command = new SqlCommand(sqlOperation.ProcedureName, conn) { CommandType = CommandType.StoredProcedure }) { foreach (var param in sqlOperation.Parameters) { command.Parameters.Add(param); } conn.Open(); command.ExecuteNonQuery(); } }