I'm designing a Data Access layer for an C#/ASP.net application and I have a question regarding the treatment of parameters in sql queries.
At the moment, when a query needs a dynamically set parameter for the Where clause I have to (1) define a variable to hold the value, (2) add a new QueryStringParameter to the SqlDataSource's SelectParameters collection, (3) set the temporary value of the parameter when the method containing the query is called, (4) and set the value of the parameter on the Selecting event of the SqlDataSource.
I have a list of ~20 parameters that are used throughout the different queries and it seems as though I should be able to define each once and simply tell the method which to use (and update it's value appropriately).
Is there a good way to set this up?