QueryBuilder Modifying Entered Query
-
13-12-2020 - |
Question
Why does QueryBuilder modify my query? Is there a workaround?
When I enter the query below, QueryBuilder modifies the query to the more complex version below, requiring additional parameters for the FillBy method. Any additional parameters adds an exponential amount of complexity to the modified query.
Entered:
SELECT prop, lot, type, created_on, done
FROM TestSelection
WHERE (prop=? OR '_NO_PROP_'=?) AND (lot=? OR '_NO_LOT_'=?)
Modified:
SELECT prop, lot, type, created_on, done
FROM TestSelection
WHERE (prop = ?) AND (lot = ?) OR
(prop = ?) AND ('_NO_LOT_' = ?) OR
(lot = ?) AND ('_NO_PROP_' = ?) OR
('_NO_LOT_' = ?) AND ('_NO_PROP_' = ?)
Goal: Allow the user to search by prop, lot, or both. My actual program will query on several additional fields.
Notes:
- WinForms Project (VB.NET if applicable)
- TestSelection is a query in a Microsoft Access database
Solution
I decided to remove any WHERE conditions in QueryBuilder. Instead, I just use a LINQ query.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow