File tree 1 file changed +20
-2
lines changed
1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -88,10 +88,13 @@ Limitations and caveats
88
88
### Combining the Where and OrWhere methods
89
89
90
90
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.
92
93
See also [ issue 647] ( https://github.com/DapperLib/Dapper/issues/647 ) .
93
94
94
- For example, when providing the following clauses
95
+ #### Example Where first
96
+
97
+ When providing the following clauses
95
98
``` csharp
96
99
sql .Where (" a = @a1" );
97
100
sql .OrWhere (" b = @b1" );
@@ -108,3 +111,18 @@ and not say
108
111
``` sql
109
112
a = @a1 OR b = @b1 AND a = @a2 OR b = @b2
110
113
```
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
+ ```
You can’t perform that action at this time.
0 commit comments