Skip to content

Commit 3ff2a7d

Browse files
committed
add Sql.In examples
1 parent bcfeb11 commit 3ff2a7d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

MyApp/_pages/ormlite/apis/select.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,30 @@ q = db.From<Track>()
196196
var top2CountOfAByYear = db.Dictionary<string, int>(q);
197197
```
198198

199+
## Sql.In
200+
201+
### Nested Typed Sub Select Sql Expressions
202+
203+
The `Sql.In()` API supports nesting and combining of multiple Typed SQL Expressions together
204+
in a single SQL Query, e.g:
205+
206+
```csharp
207+
var usaCustomerIds = db.From<Customer>(c => c.Country == "USA").Select(c => c.Id);
208+
var usaCustomerOrders = db.Select(db.From<Order>()
209+
.Where(x => Sql.In(x.CustomerId, usaCustomerIds)));
210+
```
211+
212+
### SQL IN with collections
213+
214+
By using `Sql.In` from within a `SqlExpression<T>`, multiple values can be checked for a match in your query.
215+
216+
```csharp
217+
db.Select<Author>(x => Sql.In(x.City, "London", "Madrid", "Berlin"));
218+
219+
var cities = new[] { "London", "Madrid", "Berlin" };
220+
db.Select<Author>(x => Sql.In(x.City, cities));
221+
```
222+
199223
## SqlExpression with JOIN examples
200224

201225
Just like SQL, SqlExpression supports multiple JOIN's that can leverage OrmLite's Reference Conventions for Simple, Terse and Intuitive Table JOIN's:

0 commit comments

Comments
 (0)