@@ -282,7 +282,7 @@ db.Insert(new Person { Id = 1, FirstName = "Jimi", LastName = "Hendrix", Age = 2
282282But do provide an API that takes an Expression Visitor for the rare cases you don't want to insert every field
283283
284284``` csharp
285- db .InsertOnly (new Person { FirstName = " Amy" }, q => q .Insert (p => new {p .FirstName } ));
285+ db .InsertOnly (new Person { FirstName = " Amy" }, q => q .Insert (p => new {p .FirstName }))
286286```
287287** INSERT INTO "Person" ("FirstName") VALUES ('Amy')**
288288
@@ -593,7 +593,7 @@ public class CustomerAddress
593593{
594594 [AutoIncrement ]
595595 public int Id { get ; set ; }
596- public int CustomerId { get ; set ; } // `{Parent}Id` convention to reference Customer
596+ public int CustomerId { get ; set ; } // `{Parent}Id` convention to refer to Customer
597597 public string AddressLine1 { get ; set ; }
598598 public string AddressLine2 { get ; set ; }
599599 public string City { get ; set ; }
@@ -605,7 +605,7 @@ public class Order
605605{
606606 [AutoIncrement ]
607607 public int Id { get ; set ; }
608- public int CustomerId { get ; set ; } // `{Parent}Id` convention to reference Customer
608+ public int CustomerId { get ; set ; } // `{Parent}Id` convention to refer to Customer
609609 public string LineItem { get ; set ; }
610610 public int Qty { get ; set ; }
611611 public decimal Cost { get ; set ; }
@@ -784,7 +784,9 @@ The Result Filters also lets you easily mock results and avoid hitting the datab
784784``` csharp
785785using (new OrmLiteResultsFilter {
786786 PrintSql = true ,
787- SingleResult = new Person { Id = 1 , FirstName = " Mocked" , LastName = " Person" , Age = 100 },
787+ SingleResult = new Person {
788+ Id = 1 , FirstName = " Mocked" , LastName = " Person" , Age = 100
789+ },
788790})
789791{
790792 db .Single <Person >(x => x .Age == 42 ).FirstName // Mocked
@@ -998,16 +1000,19 @@ OrmLite's T4 support can be added via NuGet with:
9981000The Custom SQL API's allow you to map custom SqlExpressions into different responses:
9991001
10001002``` csharp
1001- List < Person > results = db .SqlList <Person >(db .From <Person >().Select (" *" ).Where (q => q .Age < 50 ));
1002- List < Person > results = db .SqlList <Person >(" SELECT * FROM Person WHERE Age < @age" , new { age = 50 });
1003+ List < Person > results = db .SqlList <Person >(
1004+ db .From <Person >().Select (" *" ).Where (q => q .Age < 50 ));
1005+ List < Person > results = db .SqlList <Person >(
1006+ " SELECT * FROM Person WHERE Age < @age" , new { age = 50 });
10031007
10041008List < string > results = db .SqlColumn <string >(db .From <Person >().Select (x => x .LastName ));
10051009List < string > results = db .SqlColumn <string >(" SELECT LastName FROM Person" );
10061010
10071011HashSet < int > results = db .ColumnDistinct <int >(db .From <Person >().Select (x => x .Age ));
10081012HashSet < int > results = db .ColumnDistinct <int >(" SELECT Age FROM Person" );
10091013
1010- int result = db .SqlScalar <int >(db .From <Person >().Select (Sql .Count (" *" )).Where (q => q .Age < 50 ));
1014+ int result = db .SqlScalar <int >(
1015+ db .From <Person >().Select (Sql .Count (" *" )).Where (q => q .Age < 50 ));
10111016int result = db .SqlScalar <int >(" SELCT COUNT(*) FROM Person WHERE Age < 50" );
10121017```
10131018
@@ -1018,10 +1023,12 @@ executing Stored Procedures:
10181023
10191024``` csharp
10201025List < Poco > results = db .SqlList <Poco >(" EXEC GetAnalyticsForWeek 1" );
1021- List < Poco > results = db .SqlList <Poco >(" EXEC GetAnalyticsForWeek @weekNo" , new { weekNo = 1 });
1026+ List < Poco > results = db .SqlList <Poco >(
1027+ " EXEC GetAnalyticsForWeek @weekNo" , new { weekNo = 1 });
10221028
10231029List < int > results = db .SqlList <int >(" EXEC GetTotalsForWeek 1" );
1024- List < int > results = db .SqlList <int >(" EXEC GetTotalsForWeek @weekNo" , new { weekNo = 1 });
1030+ List < int > results = db .SqlList <int >(
1031+ " EXEC GetTotalsForWeek @weekNo" , new { weekNo = 1 });
10251032
10261033int result = db .SqlScalar <int >(" SELECT 10" );
10271034```
@@ -1462,30 +1469,30 @@ public class ShipperTypeCount
14621469Creating tables is a simple 1-liner:
14631470
14641471``` csharp
1465- using (IDbConnection db = " :memory:" .OpenDbConnection ())
1466- {
1467- db .CreateTable <ShipperType >();
1468- db .CreateTable <Shipper >();
1469- }
1470-
1471- /* In debug mode the line above prints:
1472- DEBUG: CREATE TABLE "ShipperTypes"
1473- (
1474- "ShipperTypeID" INTEGER PRIMARY KEY AUTOINCREMENT,
1475- "Name" VARCHAR(40) NOT NULL
1476- );
1477- DEBUG: CREATE UNIQUE INDEX uidx_shippertypes_name ON "ShipperTypes" ("Name" ASC);
1478- DEBUG: CREATE TABLE "Shippers"
1479- (
1480- "ShipperID" INTEGER PRIMARY KEY AUTOINCREMENT,
1481- "CompanyName" VARCHAR(40) NOT NULL,
1482- "Phone" VARCHAR(24) NULL,
1483- "ShipperTypeId" INTEGER NOT NULL,
1484-
1485- CONSTRAINT "FK_Shippers_ShipperTypes" FOREIGN KEY ("ShipperTypeId") REFERENCES "ShipperTypes" ("ShipperID")
1486- );
1487- DEBUG: CREATE UNIQUE INDEX uidx_shippers_companyname ON "Shippers" ("CompanyName" ASC);
1488- */
1472+ using (IDbConnection db = " :memory:" .OpenDbConnection ())
1473+ {
1474+ db .CreateTable <ShipperType >();
1475+ db .CreateTable <Shipper >();
1476+ }
1477+
1478+ /* In debug mode the line above prints:
1479+ DEBUG: CREATE TABLE "ShipperTypes"
1480+ (
1481+ "ShipperTypeID" INTEGER PRIMARY KEY AUTOINCREMENT,
1482+ "Name" VARCHAR(40) NOT NULL
1483+ );
1484+ DEBUG: CREATE UNIQUE INDEX uidx_shippertypes_name ON "ShipperTypes" ("Name" ASC);
1485+ DEBUG: CREATE TABLE "Shippers"
1486+ (
1487+ "ShipperID" INTEGER PRIMARY KEY AUTOINCREMENT,
1488+ "CompanyName" VARCHAR(40) NOT NULL,
1489+ "Phone" VARCHAR(24) NULL,
1490+ "ShipperTypeId" INTEGER NOT NULL,
1491+
1492+ CONSTRAINT "FK_Shippers_ShipperTypes" FOREIGN KEY ("ShipperTypeId") REFERENCES "ShipperTypes" ("ShipperID")
1493+ );
1494+ DEBUG: CREATE UNIQUE INDEX uidx_shippers_companyname ON "Shippers" ("CompanyName" ASC);
1495+ */
14891496```
14901497
14911498### Transaction Support
0 commit comments