开发者

Is it possible to return multiple result sets using ExecuteQuery in Linq to Sql?

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 w开发者_运维知识库hether 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.


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


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;
}
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜