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

Commit 952b30c

Browse files
committed
Update README.md
1 parent 837283e commit 952b30c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,6 +2309,25 @@ Db.ExecuteSql("INSERT INTO page_stats (ref_id, fav_count) VALUES (@refId, @favCo
23092309
Db.ExecuteSqlAsync("UPDATE page_stats SET view_count = view_count + 1 WHERE id = @id", new { id })
23102310
```
23112311

2312+
### INSERT INTO SELECT
2313+
2314+
You can use OrmLite's Typed `SqlExpression` to create a subselect expression that you can use to create and execute a
2315+
typed **INSERT INTO SELECT** `SqlExpression` with:
2316+
2317+
```csharp
2318+
var q = db.From<User>()
2319+
.Where(x => x.UserName == "UserName")
2320+
.Select(x => new {
2321+
x.UserName,
2322+
x.Email,
2323+
GivenName = x.FirstName,
2324+
Surname = x.LastName,
2325+
FullName = x.FirstName + " " + x.LastName
2326+
});
2327+
2328+
var id = db.InsertIntoSelect<CustomUser>(q)
2329+
```
2330+
23122331
## Stored Procedures using Custom Raw SQL API's
23132332

23142333
The Raw SQL API's provide a convenient way for mapping results of any Custom SQL like

0 commit comments

Comments
 (0)