File tree Expand file tree Collapse file tree 1 file changed +26
-5
lines changed Expand file tree Collapse file tree 1 file changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -85,10 +85,16 @@ var count = conn.ExecuteScalar<int>(countTemplate.RawSql, countTemplate.Paramete
85
85
Limitations and caveats
86
86
--------
87
87
88
- OrWhere use ` and ` not ` or ` to concat sql problem
88
+ ### Combining the Where and OrWhere methods
89
89
90
- [ Issue 647] ( https://github.com/DapperLib/Dapper/issues/647 )
90
+ The OrWhere method currently groups all ` and ` and ` or ` clauses by type,
91
+ then join the groups with ` and ` or ` or ` depending on the first call.
92
+ This may result in possibly unexpected outcomes.
93
+ See also [ issue 647] ( https://github.com/DapperLib/Dapper/issues/647 ) .
91
94
95
+ #### Example Where first
96
+
97
+ When providing the following clauses
92
98
``` csharp
93
99
sql .Where (" a = @a1" );
94
100
sql .OrWhere (" b = @b1" );
@@ -97,11 +103,26 @@ sql.OrWhere("b = @b2");
97
103
```
98
104
99
105
SqlBuilder will generate sql
100
- ``` sql=
101
- a = @a1 AND b = @b1 AND a = @a2 AND b = @b2
106
+ ``` sql
107
+ a = @a1 AND a = @a2 AND ( b = @b1 OR b = @b2 )
102
108
```
103
109
104
- not
110
+ and not say
105
111
``` sql
106
112
a = @a1 OR b = @b1 AND a = @a2 OR b = @b2
107
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