Click here to Skip to main content
15,906,463 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Hello.
I have a stored procedure that returns 3 different resultsets. I'm dragging this stored proc into my dbml file and want to return all 3 different resultsets using IMultipleResults, however when I try to request my 2nd and 3rd resultsets, they for some reason, still only return the 1st resultset again. I need to be able to retrieve these 2nd & 3rd results.
Here's my code in my datacontext file:

C#
[Function(Name="dbo.MyStoredProcName")]
        [ResultType(typeof(InventoryTransactions))]
        [ResultType(typeof(Shipments))]
        [ResultType(typeof(Receipts))]
        public IMultipleResults GetMultipleRs()
        {
            IExecuteResult result = this.ExecuteMethodCall(this, (MethodInfo) MethodInfo.GetCurrentMethod());
            return (IMultipleResults) result.ReturnValue;
        }




Then, I call it from one of 3 different methods. All 3 are listed below. The only difference between the 3 is each one attempts to return a different resultset (InventoryTransactions, Shipments, & Receipts):

C#
public List<inventorytransactions> GetIlsInventoryTransactions(DateTime startDate, DateTime endDate)
        {
            List<inventorytransactions> transactions;

            using (IlsDataContext dc = _conn.GetIlsTransactionContext())
            {
                IMultipleResults ret = dc.GetMultipleRs();
                transactions = (from t in ret.GetResult<InventoryTransactions>()
                                where t.DateTimeStamp >= startDate && t.DateTimeStamp < endDate
                                select t).ToList();
            }
            return transactions;
        }

public List<Shipments> GetIlsShipments(DateTime startDate, DateTime endDate)
        {
            List<Shipments> transactions;

            using (IlsDataContext dc = _conn.GetIlsTransactionContext())
            {
                IMultipleResults ret = dc.GetMultipleRs();
                transactions = (from t in ret.GetResult<Shipments>()
                                where t.DateTimeStamp >= startDate && t.DateTimeStamp < endDate
                                select t).ToList();
            }
            return transactions;
        }



public List<Receipts> GetIlsReceipts(DateTime startDate, DateTime endDate)
        {
            List<Receipts> transactions;

            using (IlsDataContext dc = _conn.GetIlsTransactionContext())
            {
                IMultipleResults ret = dc.GetMultipleRs();
                transactions = (from t in ret.GetResult<Receipts>()
                                where t.DateTimeStamp >= startDate && t.DateTimeStamp < endDate
                                select t).ToList();
            }
            return transactions;
        }</inventorytransactions></inventorytransactions>



--------------------------------------------------------------------------------
When I call any of these 3 methods, all 3 only return the data from the 1st resultset (InventoryTransactions). Any idea why I can't get the 2nd and 3rd ones?
Thanks.
Posted
Updated 13-Apr-11 18:11pm
v2
Comments
Pong D. Panda 14-Apr-11 1:30am    
Can you post your MyStoredProcName? Reason being is that I dont see any error on your implementation, it might be the sp that you were calling.

1 solution

You need to call the ret.GetResult<...> one after anather.
Let's presume the resultsets you are getting from SP are in following order
1st InventoryTransactions
2nd Shipments
3rd Receipts,
so Something like ret.GetResult<InventoryTransactions>, after that the 2nd resordset ret.GetResult<Shipments> and then the 3rd recordset ret.GetResult<Receipts> is required
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900