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

Commit 760f13e

Browse files
committed
Add custom SQL examples alongside Sql Expression for Custom SQL APIs
1 parent 4875f66 commit 760f13e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,16 @@ From v4.0.16 you can now use typed sql expressions in Custom SQL API's
9393

9494
```csharp
9595
List<Person> results = db.SqlList<Person>(db.From<Person>().Select("*").Where(q => q.Age < 50));
96+
List<Person> results = db.SqlList<Person>("SELECT * FROM Person WHERE Age < @age", new { age=50});
9697

97-
List<string> results = db.SqlColumn<string>(db.From<Person>().Select(x => x.LastName);
98+
List<string> results = db.SqlColumn<string>(db.From<Person>().Select(x => x.LastName));
99+
List<string> results = db.SqlColumn<string>("SELECT LastName FROM Person");
98100

99-
HashSet<int> results = db.ColumnDistinct<int>(db.From<Person>().Select(x => x.Age);
101+
HashSet<int> results = db.ColumnDistinct<int>(db.From<Person>().Select(x => x.Age));
102+
HashSet<int> results = db.ColumnDistinct<int>("SELECT Age FROM Person");
100103

101104
int result = db.SqlScalar<int>(db.From<Person>().Select(Sql.Count("*")).Where(q => q.Age < 50));
105+
int result = db.SqlScalar<int>("SELCT COUNT(*) FROM Person WHERE Age < 50");
102106
```
103107

104108
## New Simplified API

0 commit comments

Comments
 (0)