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

Commit 629d145

Browse files
authored
Merge pull request #13 from ServiceStack/master
Update from upstream 26.06.2017
2 parents de59c32 + 285f7f0 commit 629d145

File tree

99 files changed

+12975
-3073
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+12975
-3073
lines changed

NuGet.Core/ServiceStack.OrmLite.PostgreSQL.Core/ServiceStack.OrmLite.PostgreSQL.Core.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<copyright>Copyright 2017 ServiceStack</copyright>
2020
<dependencies>
2121
<group targetFramework=".NETStandard1.3">
22-
<dependency id="Npgsql" version="[3.2.2, )" />
22+
<dependency id="Npgsql" version="[3.2.3, )" />
2323
<dependency id="ServiceStack.Interfaces.Core" version="1.0.0" />
2424
<dependency id="ServiceStack.Text.Core" version="1.0.0" />
2525
<dependency id="ServiceStack.Common.Core" version="1.0.0" />

NuGet.Signed/ServiceStack.OrmLite.Sqlite.Windows.Signed/servicestack.ormlite.sqlite.windows.signed.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<language>en-US</language>
1818
<copyright>Copyright 2017 ServiceStack</copyright>
1919
<dependencies>
20-
<dependency id="System.Data.SQLite.Core" version="1.0.105.1" />
20+
<dependency id="System.Data.SQLite.Core" version="1.0.105.2" />
2121
<dependency id="ServiceStack.OrmLite.Signed" version="4.5" />
2222
</dependencies>
2323
</metadata>

NuGet/ServiceStack.OrmLite.PostgreSQL/servicestack.ormlite.postgresql.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<language>en-US</language>
1919
<copyright>Copyright 2017 ServiceStack</copyright>
2020
<dependencies>
21-
<dependency id="Npgsql" version="3.2.2" />
21+
<dependency id="Npgsql" version="3.2.3" />
2222
<dependency id="ServiceStack.OrmLite" version="4.5" />
2323
</dependencies>
2424
</metadata>

NuGet/ServiceStack.OrmLite.Sqlite.Windows/servicestack.ormlite.sqlite.windows.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<language>en-US</language>
1919
<copyright>Copyright 2017 ServiceStack</copyright>
2020
<dependencies>
21-
<dependency id="System.Data.SQLite.Core" version="1.0.105.1" />
21+
<dependency id="System.Data.SQLite.Core" version="1.0.105.2" />
2222
<dependency id="ServiceStack.OrmLite" version="4.5" />
2323
</dependencies>
2424
</metadata>

NuGet/ServiceStack.OrmLite.Sqlite/servicestack.ormlite.sqlite.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<copyright>Copyright 2017 ServiceStack</copyright>
1919
<dependencies>
2020
<dependency id="ServiceStack.OrmLite" version="4.5" />
21-
<dependency id="System.Data.SQLite.Core" version="1.0.105.1" />
21+
<dependency id="System.Data.SQLite.Core" version="1.0.105.2" />
2222
</dependencies>
2323
</metadata>
2424
<files>

README.md

Lines changed: 116 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:
854+
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+
890+
```csharp
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:
855902

856903
```csharp
857-
db.Select<List<object>>(db.From<Poco>()
858-
.Select("COUNT(*), MIN(Id), MAX(Id)"))[0].PrintDump();
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));
@@ -2316,6 +2367,60 @@ Assert.That(db.Select<Shipper>(), Has.Count.EqualTo(0));
23162367
Assert.That(db.Select<ShipperType>(), Has.Count.EqualTo(0));
23172368
```
23182369

2370+
### Soft Deletes
2371+
2372+
Select Filters let you specify a custom `SelectFilter` that lets you modify queries that use `SqlExpression<T>` before they're executed. This could be used to make working with "Soft Deletes" Tables easier where it can be made to apply a custom `x.IsDeleted != true` condition on every `SqlExpression`.
2373+
2374+
By either using a `SelectFilter` on concrete POCO Table Types, e.g:
2375+
2376+
```csharp
2377+
SqlExpression<Table1>.SelectFilter = q => q.Where(x => x.IsDeleted != true);
2378+
SqlExpression<Table2>.SelectFilter = q => q.Where(x => x.IsDeleted != true);
2379+
```
2380+
2381+
Or alternatively using generic delegate that applies to all SqlExpressions, but you'll only have access to a
2382+
`IUntypedSqlExpression` which offers a limited API surface area but will still let you execute a custom filter
2383+
for all `SqlExpression<T>` that could be used to add a condition for all tables implementing a custom
2384+
`ISoftDelete` interface with:
2385+
2386+
```csharp
2387+
OrmLiteConfig.SqlExpressionSelectFilter = q =>
2388+
{
2389+
if (q.ModelDef.ModelType.HasInterface(typeof(ISoftDelete)))
2390+
{
2391+
q.Where<ISoftDelete>(x => x.IsDeleted != true);
2392+
}
2393+
};
2394+
```
2395+
2396+
Both solutions above will transparently add the `x.IsDeleted != true` to all `SqlExpression<T>` based queries
2397+
so it only returns results which aren't `IsDeleted` from any of queries below:
2398+
2399+
```csharp
2400+
var results = db.Select(db.From<Table>());
2401+
var result = db.Single(db.From<Table>().Where(x => x.Name == "foo"));
2402+
var result = db.Single(x => x.Name == "foo");
2403+
```
2404+
2405+
### Check Constraints
2406+
2407+
OrmLite includes support for [SQL Check Constraints](https://en.wikipedia.org/wiki/Check_constraint) which will create your Table schema with the `[CheckConstraint]` specified, e.g:
2408+
2409+
```csharp
2410+
public class Table
2411+
{
2412+
[AutoIncrement]
2413+
public int Id { get; set; }
2414+
2415+
[Required]
2416+
[CheckConstraint("Age > 1")]
2417+
public int Age { get; set; }
2418+
2419+
[CheckConstraint("Name IS NOT NULL")]
2420+
public string Name { get; set; }
2421+
}
2422+
```
2423+
23192424
## SQL Server Features
23202425

23212426
### Memory Optimized Tables

build/copy.bat

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ MD ..\..\ServiceStack.OrmLite\NuGet\ServiceStack.OrmLite.T4\content
1010

1111
COPY ..\src\T4\*.* ..\..\ServiceStack.OrmLite\NuGet\ServiceStack.OrmLite.T4\content
1212

13-
COPY ..\src\ServiceStack.OrmLite\bin\%BUILD%\net45\ServiceStack.OrmLite.* ..\..\ServiceStack\lib
13+
COPY ..\src\ServiceStack.OrmLite\bin\%BUILD%\net45\ServiceStack.OrmLite.* ..\..\ServiceStack\lib\net45
1414
COPY ..\src\ServiceStack.OrmLite\bin\%BUILD%\netstandard1.3\ServiceStack.OrmLite.* ..\..\ServiceStack\lib\netstandard1.3
15-
COPY ..\src\ServiceStack.OrmLite.Sqlite\bin\%BUILD%\net45\ServiceStack.OrmLite.Sqlite.* ..\..\ServiceStack\lib
15+
COPY ..\src\ServiceStack.OrmLite.Sqlite\bin\%BUILD%\net45\ServiceStack.OrmLite.Sqlite.* ..\..\ServiceStack\lib\net45
1616
COPY ..\src\ServiceStack.OrmLite.Sqlite\bin\%BUILD%\netstandard1.3\ServiceStack.OrmLite.Sqlite.* ..\..\ServiceStack\lib\netstandard1.3
17-
COPY ..\src\ServiceStack.OrmLite.Sqlite.Windows\bin\%BUILD%\net45\ServiceStack.OrmLite.Sqlite.Windows.* ..\..\ServiceStack\lib
18-
COPY ..\src\ServiceStack.OrmLite.SqlServer\bin\%BUILD%\net45\ServiceStack.OrmLite.SqlServer.* ..\..\ServiceStack\lib
17+
COPY ..\src\ServiceStack.OrmLite.Sqlite.Windows\bin\%BUILD%\net45\ServiceStack.OrmLite.Sqlite.Windows.* ..\..\ServiceStack\lib\net45
18+
COPY ..\src\ServiceStack.OrmLite.SqlServer\bin\%BUILD%\net45\ServiceStack.OrmLite.SqlServer.* ..\..\ServiceStack\lib\net45
1919
COPY ..\src\ServiceStack.OrmLite.SqlServer\bin\%BUILD%\netstandard1.3\ServiceStack.OrmLite.SqlServer.* ..\..\ServiceStack\lib\netstandard1.3
20-
COPY ..\src\ServiceStack.OrmLite.MySql\bin\%BUILD%\net45\ServiceStack.OrmLite.MySql.* ..\..\ServiceStack\lib
20+
COPY ..\src\ServiceStack.OrmLite.MySql\bin\%BUILD%\net45\ServiceStack.OrmLite.MySql.* ..\..\ServiceStack\lib\net45
2121
COPY ..\src\ServiceStack.OrmLite.MySql\bin\%BUILD%\netstandard1.6\ServiceStack.OrmLite.MySql.* ..\..\ServiceStack\lib\netstandard1.6
22-
COPY ..\src\ServiceStack.OrmLite.PostgreSQL\bin\%BUILD%\net45\ServiceStack.OrmLite.PostgreSQL.* ..\..\ServiceStack\lib
22+
COPY ..\src\ServiceStack.OrmLite.PostgreSQL\bin\%BUILD%\net45\ServiceStack.OrmLite.PostgreSQL.* ..\..\ServiceStack\lib\net45
2323
COPY ..\src\ServiceStack.OrmLite.PostgreSQL\bin\%BUILD%\netstandard1.3\ServiceStack.OrmLite.PostgreSQL.* ..\..\ServiceStack\lib\netstandard1.3
24-
COPY ..\src\ServiceStack.OrmLite.PostgreSQL\bin\%BUILD%\net45\Npgsql.* ..\..\ServiceStack\lib
24+
COPY ..\src\ServiceStack.OrmLite.PostgreSQL\bin\%BUILD%\net45\Npgsql.* ..\..\ServiceStack\lib\net45
2525

2626
COPY ..\src\ServiceStack.OrmLite\bin\Signed\net45\ServiceStack.OrmLite.* ..\..\ServiceStack\lib\signed
2727
COPY ..\src\ServiceStack.OrmLite.SqlServer\bin\Signed\net45\ServiceStack.OrmLite.SqlServer.* ..\..\ServiceStack\lib\signed

lib/net45/ServiceStack.Client.dll

1.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)