Friday, 15 October 2010

Execute multiple select statements to a DataSet in one command

I recently had the need to improve performance on a large web app. Looking in SQL profiler I could see that there were a lot of SQL commands happening that would be more efficient if I could do multiple queries in one command. Turns out it is possible and not that hard!

Here is an abstract of the data class that handles reading data from the database:


And here is how you would call it:


The only thing you have to remember is to specify the table names so you can access them from the dataset. Ideally it would be nice to read the table names from the SQL command itself but this is for later.

No comments:

Post a Comment