I tried using the Where and OrWhere methods for SqlBuilder for Dapper, but it does not work as I expected.
The edited part of this question is basically what I came across. Since he did not receive an answer, I will ask him here.
var builder = new SqlBuilder(); var sql = builder.AddTemplate("select * from table /**where**/ "); builder.Where("a = @a", new { a = 1 }) .OrWhere("b = @b", new { b = 2 });
I was expecting select * from table WHERE a = @a OR b = @b
but I got select * from table WHERE a = @a AND b = @b
Is it possible to add OR to the where clause using SqlBuilder?
I think this is just a matter of changing the next in the SqlBuilder class to say OR instead of AND, but I wanted to confirm.
public SqlBuilder OrWhere(string sql, dynamic parameters = null) { AddClause("where", sql, parameters, " AND ", prefix: "WHERE ", postfix: "\n", IsInclusive: true); return this; }
source share