Quantcast
Channel: Param string on Dapper in WHERE clause - Stack Overflow
Browsing index pages (4 articles)
↧

Image may be NSFW.
Clik here to view.

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 Article


Answer 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 Article


Answer 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 Article

Answer 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
Browsing index pages (4 articles)


Latest Images