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

Commit ba74dc6

Browse files
committed
Update docs
1 parent 08885bc commit ba74dc6

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

README.md

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,16 @@ var q = db.From<Person>()
411411
db.UpdateOnly(new Person { FirstName = "JJ", LastName = "Hendo" }, onlyFields: q);
412412
```
413413

414+
Using an Object Dictionary:
415+
416+
```csharp
417+
var updateFields = new Dictionary<string,object> {
418+
[nameof(Person.FirstName)] = "JJ",
419+
};
420+
421+
db.UpdateOnly<Person>(updateFields, p => p.LastName == "Hendrix");
422+
```
423+
414424
Using a typed SQL Expression:
415425

416426
```csharp
@@ -2107,22 +2117,32 @@ public class PocoTable
21072117

21082118
[CustomField("DECIMAL(18,4)")]
21092119
public decimal? DecimalColumn { get; set; }
2120+
2121+
[CustomField(OrmLiteVariables.MaxText)] //= {MAX_TEXT}
2122+
public string MaxText { get; set; }
2123+
2124+
[CustomField(OrmLiteVariables.MaxTextUnicode)] //= {NMAX_TEXT}
2125+
public string MaxUnicodeText { get; set; }
21102126
}
21112127

21122128
db.CreateTable<PocoTable>();
21132129
```
21142130

2115-
Generates and executes the following SQL:
2131+
Generates and executes the following SQL in SQL Server:
21162132

21172133
```sql
21182134
CREATE TABLE "PocoTable"
21192135
(
21202136
"Id" INTEGER PRIMARY KEY,
21212137
"CharColumn" CHAR(20) NULL,
2122-
"DecimalColumn" DECIMAL(18,4) NULL
2123-
);
2138+
"DecimalColumn" DECIMAL(18,4) NULL,
2139+
"MaxText" VARCHAR(MAX) NULL,
2140+
"MaxUnicodeText" NVARCHAR(MAX) NULL
2141+
);
21242142
```
21252143

2144+
> OrmLite replaces any variable placeholders with the value in each RDBMS DialectProvider's `Variables` Dictionary.
2145+
21262146
#### Pre / Post Custom SQL Hooks when Creating and Dropping tables
21272147

21282148
Pre / Post Custom SQL Hooks allow you to inject custom SQL before and after tables are created or dropped, e.g:
@@ -2877,6 +2897,30 @@ public class Table
28772897
}
28782898
```
28792899

2900+
### Bitwise operators
2901+
2902+
The Typed SqlExpression bitwise operations support depends on the RDBMS used.
2903+
2904+
E.g. all RDBMS's support Bitwise `And` and `Or` operators:
2905+
2906+
```csharp
2907+
db.Select<Table>(x => (x.Id | 2) == 3);
2908+
db.Select<Table>(x => (x.Id & 2) == 2);
2909+
```
2910+
2911+
All RDBMS Except for SQL Server support bit shift operators:
2912+
2913+
```csharp
2914+
db.Select<Table>(x => (x.Id << 1) == 4);
2915+
db.Select<Table>(x => (x.Id >> 1) == 1);
2916+
```
2917+
2918+
Whilst only SQL Server and MySQL Support Exclusive Or:
2919+
2920+
```csharp
2921+
db.Select<Table>(x => (x.Id ^ 2) == 3);
2922+
```
2923+
28802924
## SQL Server Features
28812925

28822926
### Memory Optimized Tables

tests/ServiceStack.OrmLite.Tests/CustomSqlTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ public class PocoTable
1717

1818
[CustomField("DECIMAL(18,4)")]
1919
public decimal? DecimalColumn { get; set; }
20+
21+
[CustomField(OrmLiteVariables.MaxText)] //= {MAX_TEXT}
22+
public string MaxText { get; set; }
23+
24+
[CustomField(OrmLiteVariables.MaxTextUnicode)] //= {NMAX_TEXT}
25+
public string MaxUnicodeText { get; set; }
2026
}
2127

2228
[PreCreateTable("CREATE INDEX udxNoTable on NonExistingTable (Name);")]
@@ -71,6 +77,8 @@ public class CustomSqlTests
7177
[Test]
7278
public void Can_create_field_with_custom_sql()
7379
{
80+
OrmLiteConfig.BeforeExecFilter = cmd => cmd.GetDebugString().Print();
81+
7482
using (var db = OpenDbConnection())
7583
{
7684
db.DropAndCreateTable<PocoTable>();

0 commit comments

Comments
 (0)