I’m converting a web forms application to mvc3 , for the current database it is calling asmx web services returning datasets. Since I’m rebuilding quite a bit of the application I really have no need or desire to be working with datasets. Entity Framework is out of the question for the boss etc… Thus this is the existing type of Oracle code which returns 3 refcursors resulting in the dataset containing 3 datatables. Here is the existing code:
connection = new OracleConnection(EnvironmentSettings.connectionString);
connection.Open();
command = new OracleCommand("H16B.WEB_FACILITY.get_facility_queue", connection);
command.CommandType = CommandType.StoredProcedure;
// Input Parameters
command.Parameters.Add("pfacility", OracleDbType.Varchar2, facilityCode, ParameterDirection.Input);
// Output Parameters
command.Parameters.Add("pqueue", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
command.Parameters.Add("psubmitting", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
command.Parameters.Add("psubmitted", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
adapter = new OracleDataAdapter(command);
DataSet ds = new DataSet();
adapter.Fill(ds);
So What I would like to do is instead of using a dataset, use a collection a List or IEnumerable . Could anyone show me how to capture the data into the list (would I want 3 lists , the current webmethod output is a dataset. Thanks in advance.
If you use Command.ExecuteNonQuery(), each of your ref cursor parameters should contain a Value that is either an OracleDataReader or an OracleRefCursor, depending on the internal settings of the parameter.
So, you should be able to start with something like this:
If it turns out to be an OracleRefCursor instead, you can use a GetDataReader on it for the same effect.
Since the contents are simple in this case, you may be able to just cast it to an IEnumerable directly; otherwise, you may need to fill a generic list or collection.