Param string on Dapper in WHERE clause
I'm having troubles with my param string on my WHERE clause of my method. I'm trying to do a query like this:string query = "SELECT * FROM table WHERE Name @Filter OR Email @Filter";And then inside my...
View ArticleAnswer by MestreDosMagros for Param string on Dapper in WHERE clause
Probably Dapper is using this query:SELECT * FROM table WHERE Name = IS NULL OR Email = IS NULLwhich is invalid.First create a profiler to see what query dapper is actually executing on the database...
View ArticleAnswer by dbso for Param string on Dapper in WHERE clause
I don't think you can use parameters from Dapper like this.To have a valid query you'd need to haveSELECT * FROM table WHERE Name = @Filter OR Email = @Filter;But that won't work with null.You actually...
View ArticleAnswer by StefanFFM for Param string on Dapper in WHERE clause
Rewrite the query to:SELECT * FROM table WHERE (@Filter is null and Email is null or @Filter = Email) OR (@Filter is null and Name is null or @Filter = Name)In that case you can set the parameter...
View Article