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

Commit 4d0219c

Browse files
committed
Add additional preferred API's for ShipperExample
1 parent d9f96d7 commit 4d0219c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/ServiceStack.OrmLite.Tests/ShippersExample.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,13 @@ public void Shippers_UseCase()
9292
db.Insert(new Shipper { CompanyName = "Planes R Us", Phone = "555-PLANES", ShipperTypeId = planesType.Id });
9393
db.Insert(new Shipper { CompanyName = "We do everything!", Phone = "555-UNICORNS", ShipperTypeId = planesType.Id });
9494

95-
var trainsAreUs = db.SingleFmt<Shipper>("ShipperTypeId = {0}", trainsType.Id);
95+
var trainsAreUs = db.Single<Shipper>(q => q.ShipperTypeId == trainsType.Id);
96+
Assert.That(trainsAreUs.CompanyName, Is.EqualTo("Trains R Us"));
97+
98+
trainsAreUs = db.SingleFmt<Shipper>("ShipperTypeId = {0}", trainsType.Id);
9699
Assert.That(trainsAreUs.CompanyName, Is.EqualTo("Trains R Us"));
97100

101+
98102
Assert.That(db.Select<Shipper>(q => q.CompanyName == "Trains R Us" || q.Phone == "555-UNICORNS"), Has.Count.EqualTo(2));
99103
Assert.That(db.SelectFmt<Shipper>("CompanyName = {0} OR Phone = {1}", "Trains R Us", "555-UNICORNS"), Has.Count.EqualTo(2));
100104

@@ -116,15 +120,14 @@ public void Shippers_UseCase()
116120

117121
//Performing custom queries
118122
//Select only a subset from the table
119-
var partialColumns = db.Select<SubsetOfShipper>(
120-
db.From<Shipper>().Where(q => q.ShipperTypeId == 2));
123+
var partialColumns = db.Select<SubsetOfShipper>(db.From<Shipper>().Where(q => q.ShipperTypeId == 2));
121124
Assert.That(partialColumns, Has.Count.EqualTo(2));
122125

123126
partialColumns = db.SelectFmt<SubsetOfShipper>(typeof (Shipper), "ShipperTypeId = {0}", planesType.Id);
124127
Assert.That(partialColumns, Has.Count.EqualTo(2));
125128

126129
//Select into another POCO class that matches sql
127-
var rows = db.SelectFmt<ShipperTypeCount>(
130+
var rows = db.SqlList<ShipperTypeCount>(
128131
"SELECT ShipperTypeId, COUNT(*) AS Total FROM Shippers GROUP BY ShipperTypeId ORDER BY COUNT(*)");
129132

130133
Assert.That(rows, Has.Count.EqualTo(2));

0 commit comments

Comments
 (0)