Skip to content

Commit caf92e8

Browse files
committed
Add example with OrWhere call first
1 parent 39a07dc commit caf92e8

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Dapper.SqlBuilder/Readme.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,13 @@ Limitations and caveats
8888
### Combining the Where and OrWhere methods
8989

9090
The OrWhere method currently groups all `and` and `or` clauses by type,
91-
which may result in possibly unexpected outcomes.
91+
then join the groups with `and` or `or` depending on the first call.
92+
This may result in possibly unexpected outcomes.
9293
See also [issue 647](https://github.com/DapperLib/Dapper/issues/647).
9394

94-
For example, when providing the following clauses
95+
#### Example Where first
96+
97+
When providing the following clauses
9598
```csharp
9699
sql.Where("a = @a1");
97100
sql.OrWhere("b = @b1");
@@ -108,3 +111,18 @@ and not say
108111
```sql
109112
a = @a1 OR b = @b1 AND a = @a2 OR b = @b2
110113
```
114+
115+
#### Example OrWhere first
116+
117+
When providing the following clauses
118+
```csharp
119+
sql.OrWhere("b = @b1");
120+
sql.Where("a = @a1");
121+
sql.OrWhere("b = @b2");
122+
sql.Where("a = @a2");
123+
```
124+
125+
SqlBuilder will generate sql
126+
```sql
127+
a = @a1 OR a = @a2 OR ( b = @b1 OR b = @b2 )
128+
```

0 commit comments

Comments
 (0)