Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit fffbc94

Browse files
committed
Update docs w/ rel-notes
1 parent 93f9d93 commit fffbc94

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ We've also added a
182182
as it's a common use-case to swapout to use Sqlite's in-memory provider for faster tests.
183183
But as Sqlite doesn't provide async API's under-the-hood we fallback to *pseudo async* support where we just wrap its synchronous responses in `Task` results.
184184

185+
## [OrmLite Interactive Tour](http://gistlyn.com/ormlite)
186+
187+
The best way to learn about OrmLite is to take the [OrmLite Interactive Tour](http://gistlyn.com/ormlite)
188+
on Gistlyn which lets you try out and explore OrmLite features from the comfort of your own browser:
189+
190+
[![](https://raw.githubusercontent.com/ServiceStack/Assets/master/img/livedemos/gistlyn/ormlite-screenshot.png)](http://gistlyn.com/ormlite)
191+
185192
## Nested Typed Sub SqlExpressions
186193

187194
The `Sql.In()` API supports nesting and combining of multiple Typed SQL Expressions together
@@ -231,6 +238,14 @@ db.Select<Author>(x => x.Name.Contains("Benedict"));
231238
db.Select<Author>(x => x.Rate == 10 && x.City == "Mexico");
232239
```
233240

241+
```csharp
242+
db.Select<Author>(x => x.Rate.ToString() == "10"); //impicit string casting
243+
```
244+
245+
```csharp
246+
db.Select<Author>(x => "Rate " + x.Rate == "Rate 10"); //server string concatenation
247+
```
248+
234249
### Convenient common usage data access patterns
235250

236251
OrmLite also includes a number of convenient API's providing DRY, typed data access for common queries:
@@ -1080,6 +1095,73 @@ var customerWithAddress = db.LoadSingleById<Customer>(customer.Id, include: new[
10801095
var customerWithAddress = db.LoadSingleById<Customer>(customer.Id, include: x => new { x.PrimaryAddress });
10811096
```
10821097

1098+
### Custom Select with JOIN
1099+
1100+
You can specify SQL Aliases for ambiguous columns using anonymous properties, e.g:
1101+
1102+
```csharp
1103+
var q = db.From<Table>()
1104+
.Join<JoinedTable>()
1105+
.Select<Table, JoinedTable>((a, b) => new { a, JoinId = b.Id, JoinName = b.Name });
1106+
```
1107+
1108+
Which is roughly equivalent to:
1109+
1110+
SELECT a.*, b.Id AS JoinId, b.Name AS JoinName
1111+
1112+
Where it selects all columns from the primary `Table` as well as `Id` and `Name` columns from `JoinedTable,`
1113+
returning them in the `JoinId` and `JoinName` custom aliases.
1114+
1115+
### Nested JOIN Table Expressions
1116+
1117+
You can also query POCO References on JOIN tables, e.g:
1118+
1119+
```csharp
1120+
var q = db.From<Table>()
1121+
.Join<Join1>()
1122+
.Join<Join1, Join2>()
1123+
.Where(x => !x.IsValid.HasValue &&
1124+
x.Join1.IsValid &&
1125+
x.Join1.Join2.Name == theName &&
1126+
x.Join1.Join2.IntValue == intValue)
1127+
.GroupBy(x => x.Join1.Join2.IntValue)
1128+
.Having(x => Sql.Max(x.Join1.Join2.IntValue) != 10)
1129+
.Select(x => x.Join1.Join2.IntValue);
1130+
```
1131+
1132+
### JOIN aliases
1133+
1134+
You can specify join aliases when joining multiple of the same table together, e.g:
1135+
1136+
```csharp
1137+
var q = db.From<Sale>()
1138+
.LeftJoin<ContactIssue>((s,c) => s.SellerId == c.Id, db.JoinAlias("seller"))
1139+
.LeftJoin<ContactIssue>((s,c) => s.BuyerId == c.Id, db.JoinAlias("buyer"))
1140+
.Select<Sale, ContactIssue>((s,c) => new {
1141+
s,
1142+
BuyerFirstName = Sql.JoinAlias(c.FirstName, "buyer"),
1143+
BuyerLastName = Sql.JoinAlias(c.LastName, "buyer"),
1144+
SellerFirstName = Sql.JoinAlias(c.FirstName, "seller"),
1145+
SellerLastName = Sql.JoinAlias(c.LastName, "seller"),
1146+
});
1147+
```
1148+
1149+
### SQL Server Table Hints
1150+
1151+
Using the same JOIN Filter feature OrmLite also lets you add SQL Server Hints on JOIN Table expressions, e.g:
1152+
1153+
```csharp
1154+
var q = db.From<Car>()
1155+
.Join<Car, CarType>((c, t) => c.CarId == t.CarId, SqlServerTableHint.ReadUncommitted);
1156+
```
1157+
1158+
Which emits the appropriate SQL Server hints:
1159+
1160+
```sql
1161+
SELECT "Car"."CarId", "CarType"."CarTypeName"
1162+
FROM "Car" INNER JOIN "CarType" WITH (READUNCOMMITTED) ON ("Car"."CarId" = "CarType"."CarId")
1163+
```
1164+
10831165
## Optimistic Concurrency
10841166

10851167
Optimistic concurrency can be added to any table by adding the `ulong RowVersion { get; set; }` property, e.g:

0 commit comments

Comments
 (0)