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

Commit 2e0ffe7

Browse files
committed
Update README.md
1 parent 97d20b8 commit 2e0ffe7

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,23 @@ foreach (var person in lazyQuery) {
886886
//...
887887
}
888888
```
889+
890+
### Save Methods
891+
892+
`Save` and `SaveAll` will Insert if no record with **Id** exists, otherwise it Updates.
893+
894+
`Save` will populate any `[AutoIncrement]` or `[AutoId]` Primary Keys, e.g:
895+
896+
```csharp
897+
db.Save(item);
898+
item.Id // RDBMS populated Auto Id
899+
```
900+
901+
Alternatively you can also manually Select and Retrieve the Inserted RDBMS Auto Id in a single query with `Insert` APIs by specifying `selectIdentity:true`:
902+
903+
```csharp
904+
item.Id = db.Insert(item, selectIdentity:true);
905+
```
889906

890907
#### Other examples
891908

@@ -896,7 +913,6 @@ var topVIPs = db.WhereLazy<Person>(new { Age = 27 }).Where(p => IsVip(p)).Take(5
896913
### Other Notes
897914

898915
- All **Insert**, **Update**, and **Delete** methods take multiple params, while `InsertAll`, `UpdateAll` and `DeleteAll` take IEnumerables.
899-
- `Save` and `SaveAll` will Insert if no record with **Id** exists, otherwise it Updates.
900916
- Methods containing the word **Each** return an IEnumerable<T> and are lazily loaded (i.e. non-buffered).
901917

902918
# Features

0 commit comments

Comments
 (0)