Fastest way to run SQL on multidimensional array

I want to take a table represented by a multidimensional string array (column names in another array) and use a SQL SELECT statement to get a subset of the rows.

To catch:

  • the table is entered by the user (different table)
  • SQL is also entered by the user

If necessary:

  • Create table in SQL
  • Populating a table in SQL
  • Request a table

or is it a simpler solution? For example. converting a multidimensional array to a DataTable and then executing SQL on that object?

+2


source to share


2 answers


I think you could use DataTable for this. It is usually used to store data retrieved from a database, but you can populate it manually. The best part is the DataTable.Select () method, which allows you to write only the WHERE clause of the query and return the corresponding rows.



+3


source


You can create your own expression tree representing the query that the user enters. This is how Link works under the hood. If you could give an example of what you are trying to achieve, it might help that you are going to write an application in C # for the web, for example.

For example, if you allow your users to enter new rows, in some kind of GUI to the table, could you do it in the datagrid and enable a column filter to achieve the above result?



In a web application, you can have an input box above each column. Users can enter data to filter this column.

+1


source







All Articles