What is the standard way to implement optional query parameters in a .NET WinForms application?
In other words, only query on a field if the value of a corresponding control is not null.
Note: Prefer VB.NET answers (C# okay too)
EDIT: I use a FillBy method which calls a query in my Access database. In the TableAdapter query editor, I just used WHERE (field1 = ?) AND (field2 = ?) ... I just can’t find the “hook” to bind form controls to the table adapter query parameters and so that if a form uses the default value to not query on it.
You can apply LINQ
Whereclause many times.If you’re working with a
DataSet, you can callAsEnumerable(available since .NET 3.5) to do LINQ queries on it.