Skip to content

Commit

Permalink
add Sql.In examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Aug 28, 2024
1 parent bcfeb11 commit 3ff2a7d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions MyApp/_pages/ormlite/apis/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,30 @@ q = db.From<Track>()
var top2CountOfAByYear = db.Dictionary<string, int>(q);
```

## Sql.In

### Nested Typed Sub Select Sql Expressions

The `Sql.In()` API supports nesting and combining of multiple Typed SQL Expressions together
in a single SQL Query, e.g:

```csharp
var usaCustomerIds = db.From<Customer>(c => c.Country == "USA").Select(c => c.Id);
var usaCustomerOrders = db.Select(db.From<Order>()
.Where(x => Sql.In(x.CustomerId, usaCustomerIds)));
```

### SQL IN with collections

By using `Sql.In` from within a `SqlExpression<T>`, multiple values can be checked for a match in your query.

```csharp
db.Select<Author>(x => Sql.In(x.City, "London", "Madrid", "Berlin"));

var cities = new[] { "London", "Madrid", "Berlin" };
db.Select<Author>(x => Sql.In(x.City, cities));
```

## SqlExpression with JOIN examples

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

0 comments on commit 3ff2a7d

Please sign in to comment.