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

Commit 80ada79

Browse files
committed
Update README with v4.5.10 fetures
1 parent 9979c39 commit 80ada79

File tree

1 file changed

+62
-11
lines changed

1 file changed

+62
-11
lines changed

README.md

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ level public properties.
4242
- [ServiceStack.OrmLite.SqlServer](http://nuget.org/List/Packages/ServiceStack.OrmLite.SqlServer)
4343
- [ServiceStack.OrmLite.PostgreSQL](http://nuget.org/List/Packages/ServiceStack.OrmLite.PostgreSQL)
4444
- [ServiceStack.OrmLite.MySql](http://nuget.org/List/Packages/ServiceStack.OrmLite.MySql)
45-
- [ServiceStack.OrmLite.Sqlite.Mono](http://nuget.org/packages/ServiceStack.OrmLite.Sqlite.Mono) - Compatible with Mono / Windows (x86)
46-
- [ServiceStack.OrmLite.Sqlite.Windows](http://nuget.org/List/Packages/ServiceStack.OrmLite.Sqlite.Windows) - 32/64bit Mixed mode .NET for Windows only
45+
- [ServiceStack.OrmLite.Sqlite](http://nuget.org/packages/ServiceStack.OrmLite.Sqlite)
4746
- [ServiceStack.OrmLite.Oracle](http://nuget.org/packages/ServiceStack.OrmLite.Oracle) (unofficial)
4847
- [ServiceStack.OrmLite.Firebird](http://nuget.org/List/Packages/ServiceStack.OrmLite.Firebird) (unofficial)
4948
- [ServiceStack.OrmLite.VistaDb](http://nuget.org/List/Packages/ServiceStack.OrmLite.VistaDb) (unofficial)
@@ -194,7 +193,7 @@ Currently only a limited number of RDBMS providers offer async API's, which at t
194193
- [MySQL .NET 4.5+](https://www.nuget.org/packages/ServiceStack.OrmLite.MySql)
195194

196195
We've also added a
197-
[.NET 4.5 build for Sqlite](https://www.nuget.org/packages/ServiceStack.OrmLite.Sqlite.Mono)
196+
[.NET 4.5 build for Sqlite](https://www.nuget.org/packages/ServiceStack.OrmLite.Sqlite)
198197
as it's a common use-case to swapout to use Sqlite's in-memory provider for faster tests.
199198
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.
200199

@@ -851,11 +850,61 @@ The mapping also includes a fallback for referencing fully-qualified names in th
851850

852851
## Dynamic Result Sets
853852

854-
There's new support for returning unstructured resultsets letting you Select `List<object>` instead of having results mapped to a concrete Poco class, e.g:
853+
In addition to populating Typed POCOs, OrmLite has a number of flexible options for accessing dynamic resultsets with adhoc schemas:
855854

855+
### C# 7 Value Tuples
856+
857+
The C# 7 Value Tuple support enables a terse, clean and typed API for accessing the Dynamic Result Sets returned when using a custom Select expression:
858+
859+
```csharp
860+
var query = db.From<Employee>()
861+
.Join<Department>()
862+
.OrderBy(e => e.Id)
863+
.Select<Employee, Department>(
864+
(e, d) => new { e.Id, e.LastName, d.Name });
865+
866+
var results = db.Select<(int id, string lastName, string deptName)>(query);
867+
868+
var row = results[i];
869+
$"row: ${row.id}, ${row.lastName}, ${row.deptName}".Print();
870+
```
871+
872+
Full Custom SQL Example:
873+
874+
```csharp
875+
var results = db.SqlList<(int count, string min, string max, int sum)>(
876+
"SELECT COUNT(*), MIN(Word), MAX(Word), Sum(Total) FROM Table");
877+
```
878+
879+
Partial Custom SQL Select Example:
880+
881+
```csharp
882+
var query = db.From<Table>()
883+
.Select("COUNT(*), MIN(Word), MAX(Word), Sum(Total)");
884+
885+
var result = db.Single<(int count, string min, string max, int sum)>(query);
886+
```
887+
888+
Same as above, but using Typed APIs:
889+
856890
```csharp
857-
db.Select<List<object>>(db.From<Poco>()
858-
.Select("COUNT(*), MIN(Id), MAX(Id)"))[0].PrintDump();
891+
var result = db.Single<(int count, string min, string max, int sum)>(
892+
db.From<Table>()
893+
.Select(x => new {
894+
Count = Sql.Count("*"),
895+
Min = Sql.Min(x.Word),
896+
Max = Sql.Max(x.Word),
897+
Sum = Sql.Sum(x.Total)
898+
}));
899+
```
900+
901+
There's also support for returning unstructured resultsets in `List<object>`, e.g:
902+
903+
```csharp
904+
var results = db.Select<List<object>>(db.From<Poco>()
905+
.Select("COUNT(*), MIN(Id), MAX(Id)"));
906+
907+
results[0].PrintDump();
859908
```
860909

861910
Output of objects in the returned `List<object>`:
@@ -869,8 +918,10 @@ Output of objects in the returned `List<object>`:
869918
You can also Select `Dictionary<string,object>` to return a dictionary of column names mapped with their values, e.g:
870919

871920
```csharp
872-
db.Select<Dictionary<string,object>>(db.From<Poco>()
873-
.Select("COUNT(*) Total, MIN(Id) MinId, MAX(Id) MaxId"))[0].PrintDump();
921+
var results = db.Select<Dictionary<string,object>>(db.From<Poco>()
922+
.Select("COUNT(*) Total, MIN(Id) MinId, MAX(Id) MaxId"));
923+
924+
results[0].PrintDump();
874925
```
875926

876927
Output of objects in the returned `Dictionary<string,object>`:
@@ -884,8 +935,8 @@ Output of objects in the returned `Dictionary<string,object>`:
884935
and can be used for API's returning a **Single** row result:
885936

886937
```csharp
887-
db.Single<List<object>>(db.From<Poco>()
888-
.Select("COUNT(*) Total, MIN(Id) MinId, MAX(Id) MaxId")).PrintDump();
938+
var result = db.Single<List<object>>(db.From<Poco>()
939+
.Select("COUNT(*) Total, MIN(Id) MinId, MAX(Id) MaxId"));
889940
```
890941

891942
or use `object` to fetch an unknown **Scalar** value:
@@ -1896,7 +1947,7 @@ dbFactory.Run(db => db.CreateTable<MasterRecord>(overwrite:false));
18961947
NoOfShards.Times(i => {
18971948
var namedShard = "robots-shard" + i;
18981949
dbFactory.RegisterConnection(namedShard,
1899-
"~/App_Data/{0}.sqlite".Fmt(shardId).MapAbsolutePath(), //Connection String
1950+
$"~/App_Data/{shardId}.sqlite".MapAbsolutePath(), //Connection String
19001951
SqliteDialect.Provider);
19011952

19021953
dbFactory.OpenDbConnection(namedShard).Run(db => db.CreateTable<Robot>(overwrite:false));

0 commit comments

Comments
 (0)