In ADO.NET you can add parameters to a command object to securely add user input to a SQL query. What is the equivalent for the other predicates common to a SQL query?
I am writing a program that is essentially a very limited O-R mapper and SQL generator (it's focused heavily around a database with meta-information and other databases that conform to that meta-data). As a result I need to be able to call stuff like:
string sql = "select " + USER_SELECTED_COLUMNS +
" from " + USER_SELECTED_TABLE +
" where " + USER_CRITERIA;
Some of it (like the criteria
) is literally entered into my program by trusted users (other developers in my company), while other data is entered into my program by untrusted users (clients) through their searches, etc.
I'd like to make this program secure, and I'm aware that the above is not. Currently I have the USER_SELECTED_COLUMNS
replaced with command parameters, but I've not been able to find the equivalent for the CRITERIA and TABLEs. (Or the order-by columns). Are there any ADO.NET features similar to SqlParameter
that I can use for non-selection predicates?