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
8585Limitations 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+ 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 ) .
9194
95+ #### Example Where first
96+
97+ When providing the following clauses
9298``` csharp
9399sql .Where (" a = @a1" );
94100sql .OrWhere (" b = @b1" );
@@ -97,11 +103,26 @@ sql.OrWhere("b = @b2");
97103```
98104
99105SqlBuilder 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 )
102108```
103109
104- not
110+ and not say
105111``` sql
106112a = @a1 OR b = @b1 AND a = @a2 OR b = @b2
107113```
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