5

I know that you can return multiple results from a stored procedure and through the method generated by the designer.

However, I'm trying to do the same using ExecuteQuery but it doesn't seem like it's possible. Has anyone tried or know whether this is possible?

Basically I'm trying to run an ad-hoc stored procedure. By ad-hoc, I mean a stored procedure that wasn't available during design-time.

MAXE
  • 4,978
  • 2
  • 45
  • 61
Jiho Han
  • 1,610
  • 1
  • 19
  • 41
  • 2
    It appears the ExecuteQuery, since it always returns IENumerable, is always going to only process the first resultset. You will want to work with IMultipleResults instead. [This](http://msdn.microsoft.com/en-us/library/system.data.linq.imultipleresults.aspx) may be a starting point. – Ross Presser Sep 18 '12 at 03:09
  • @RossPresser: Your comment seems to answer the question exactly, providing an explanation and even pointing to a possible solution for the problem in question. Please consider converting your comment into an answer. – Andriy M Nov 06 '12 at 06:44

2 Answers2

2

It appears that ExecuteQuery, since it always returns IENumerable, is always going to only process the first resultset. You will want to work with IMultipleResults instead. This may be a starting point: http://www.a2zmenu.com/Blogs/LINQ/multiple-result-sets-using-IMultipleResults-in-linq.aspx

Ross Presser
  • 6,027
  • 1
  • 34
  • 66
-1

Yes you can add your own method in your Global.CS file, which can return the DataSet with the multiple table results,

You can do something like this.

public DataSet DealClientSearchSelectTest(int ID,int PageIndex, string SearchStr)
{
 try
{
return GlobalCls.ExecuteStoredProcedure("Sp_test " + SectionID + "," + ID + '" + SearchStr + "'");
}
catch (Exception)
{
throw;
}
}
Mayur Desai
  • 683
  • 5
  • 13