Is it possible to add and remove criteria on the fly with dapper? I need this to implement user driven filtering. It is not feasible to have a query for each filter as there are too many combinations.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
At the most basic level, you can just build the TSQL dynamically in a StringBuilder – adding extra
and c.Name = @nameetc . Don’t worry about extra parameters; send them all – the library inspects the command and doesn’t add any parameters that obviously aren’t used. There is a second, newer API for this specific scenario, but I can’t remember the specifics without checking (and I’m not at a computer). I can try to add more details later (assuming Sam doesn’t).