Skip to content

Commit 39a07dc

Browse files
committed
Fix and clarify OrWhere caveats in SqlBuilder docs
1 parent bd4f75b commit 39a07dc

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Diff for: Dapper.SqlBuilder/Readme.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@ var count = conn.ExecuteScalar<int>(countTemplate.RawSql, countTemplate.Paramete
8585
Limitations and caveats
8686
--------
8787

88-
OrWhere use `and` not `or` to concat sql problem
88+
### Combining the Where and OrWhere methods
8989

90-
[Issue 647](https://github.com/DapperLib/Dapper/issues/647)
90+
The OrWhere method currently groups all `and` and `or` clauses by type,
91+
which may result in possibly unexpected outcomes.
92+
See also [issue 647](https://github.com/DapperLib/Dapper/issues/647).
9193

94+
For example, when providing the following clauses
9295
```csharp
9396
sql.Where("a = @a1");
9497
sql.OrWhere("b = @b1");
@@ -97,11 +100,11 @@ sql.OrWhere("b = @b2");
97100
```
98101

99102
SqlBuilder will generate sql
100-
```sql=
101-
a = @a1 AND b = @b1 AND a = @a2 AND b = @b2
103+
```sql
104+
a = @a1 AND a = @a2 AND ( b = @b1 OR b = @b2 )
102105
```
103106

104-
not
107+
and not say
105108
```sql
106109
a = @a1 OR b = @b1 AND a = @a2 OR b = @b2
107110
```

0 commit comments

Comments
 (0)