0

I am using following code block to get a result set from my database's stored procedure and it is working perfectly.

IEnumerable<ServiceDetails> results;
using (var myContext = new KsStadEntities())
{             
    results = myContext.Database.SqlQuery<ServiceDetails>("GetServicePriceDetails @PostalCode, @CustomerTypeRefId, @ServiceRefId", parameterList.ToArray()).ToList();                 
}

Now I have another result set that need to get it from same stored procedure, I tried other stackoverflow questions and some other articles but couldn't find any solution.

If anyone can suggest me a solution, would be very much appreciate.

help-info.de
  • 6,695
  • 16
  • 39
  • 41
  • Do you really need to get two tables out of the same call? Why wouldn't you just query the procedure again with a second set of parameters and populate a new IEnumerable? – Ryan B. Oct 02 '18 at 19:19
  • 2
    Possible duplicate of [Handle multiple result from a stored procedure with SqlQuery](https://stackoverflow.com/questions/25304791/handle-multiple-result-from-a-stored-procedure-with-sqlquery) – jtate Oct 02 '18 at 21:32
  • @Greenspark within my SP, im doing a calculation and getting summarized details from one result set (totoalPrice, total discount,..etc) with the other result set i need to get the breakdown of calculation, calculation is bit complex and with my requirement cant split it into two SPs. thats why i need to return two result set and those result sets are tempery tables within SP . Thanks – Thilanka Ishara Gunathilake Oct 03 '18 at 02:58
  • @jtate thanks for sharing, but in above example its using ADO .net to run SP, but i need to use EF, any thoughts ? – Thilanka Ishara Gunathilake Oct 03 '18 at 03:01
  • 2
    Did you look at this https://learn.microsoft.com/en-us/ef/ef6/modeling/designer/advanced/multiple-result-sets. The link @jtate is not using ado.net. In order to get multiple result sets working we need to drop to the ObjectContext API by using the IObjectContextAdapter interface. This data are still materialized in to your model. – Eldho Oct 03 '18 at 07:11
  • yes @Eldho , you are correct I was looking for a solution which I can use same SqlQuery function, seems like its not supporting. – Thilanka Ishara Gunathilake Oct 03 '18 at 13:40

0 Answers0