Quantcast
Channel: Param string on Dapper in WHERE clause - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Param string on Dapper in WHERE clause

$
0
0

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 switch their cases will be like:

public async Task<List<DTO>>Get(FilterDTO filter){    foreach(var f in filter.fields)    {        switch(f.Operator)        {            case 1:                if(f.Value == null)                {                   f.Value = "IS NULL";                   queryResult = connection.Query<Model>(query, new {Filter = f.Filter});                   break;                }                else                    goto case 2;

I'm having a lot of troubles with my param string because I cannot see what is failing on debug

enter image description here

Notice my real value name is FilterValue (this code it's a simplification)

I get this error:

Incorrect syntax near @Filter

So I know something is wrong about my param string input but I cannot see what is it


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images