GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Updated QueryWith tests · ThatRendle/Simple.Data@b9da611

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .gitignore
  • Simple.Data.Ado
    • Simple.Data.Ado.csproj
  • Simple.Data.BehaviourTest/Query
    • WithTest.cs
  • Simple.Data.SqlTest
    • QueryTest.cs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.gitignore‎

Copy file name to clipboardExpand all lines: .gitignore
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ packages/Microsoft.Web.Infrastructure.1.0.0.0/
3737
packages/Modernizr.2.5.3/
3838
packages/jQuery.1.7.1.1/
3939
packages/jQuery.UI.Combined.1.8.20.1/
40-
packages/jQuery.Validation.1.9.0.1/
40+
packages/jQuery.Validation.1.9.0.1/
41+
Simple.Data.sln.ide
Collapse file

‎Simple.Data.Ado/Simple.Data.Ado.csproj‎

Copy file name to clipboardExpand all lines: Simple.Data.Ado/Simple.Data.Ado.csproj
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<Compile Include="DeleteHelper.cs" />
8888
<Compile Include="DictionaryExtensions.cs" />
8989
<Compile Include="EagerLoadingEnumerable.cs" />
90+
<Compile Include="EventHandlerEx.cs" />
9091
<Compile Include="ExpressionFormatter.cs" />
9192
<Compile Include="ExpressionFormatterBase.cs" />
9293
<Compile Include="ExpressionHasher.cs" />
Collapse file

‎Simple.Data.BehaviourTest/Query/WithTest.cs‎

Copy file name to clipboardExpand all lines: Simple.Data.BehaviourTest/Query/WithTest.cs
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ protected override void SetSchema(MockSchemaProvider schemaProvider)
1414
new[] { "dbo", "Activity", "BASE TABLE" },
1515
new[] { "dbo", "Customer", "BASE TABLE" },
1616
new[] { "dbo", "Order", "BASE TABLE" },
17+
new[] { "dbo", "Item", "BASE TABLE" },
1718
new[] { "dbo", "Note", "BASE TABLE" },
1819
new[] { "dbo", "Activity_Join", "BASE TABLE" },
1920
new[] { "dbo", "Location", "BASE_TABLE" });
@@ -29,6 +30,9 @@ protected override void SetSchema(MockSchemaProvider schemaProvider)
2930
new[] { "dbo", "Order", "Id" },
3031
new[] { "dbo", "Order", "CustomerId" },
3132
new[] { "dbo", "Order", "Description" },
33+
new[] { "dbo", "Item", "Id" },
34+
new[] { "dbo", "Item", "OrderId" },
35+
new[] { "dbo", "Item", "Description" },
3236
new[] { "dbo", "Note", "Id" },
3337
new[] { "dbo", "Note", "CustomerId" },
3438
new[] { "dbo", "Note", "Text" },
@@ -44,6 +48,7 @@ protected override void SetSchema(MockSchemaProvider schemaProvider)
4448
new object[] {"dbo", "Department", "Id", 0},
4549
new object[] {"dbo", "Customer", "Id", 0},
4650
new object[] {"dbo", "Order", "Id", 0},
51+
new object[] {"dbo", "Item", "Id", 0},
4752
new object[] {"dbo", "Note", "Id", 0}
4853
);
4954

@@ -52,6 +57,7 @@ protected override void SetSchema(MockSchemaProvider schemaProvider)
5257
new object[] { "FK_Activity_Join_Activity", "dbo", "Activity_Join", "ID_Activity", "dbo", "Activity", "ID", 0 },
5358
new object[] { "FK_Activity_Join_Location", "dbo", "Activity_Join", "ID_Location", "dbo", "Location", "ID", 0 },
5459
new object[] { "FK_Order_Customer", "dbo", "Order", "CustomerId", "dbo", "Customer", "Id", 0 },
60+
new object[] { "FK_Item_Order", "dbo", "Item", "OrderId", "dbo", "Order", "Id", 0 },
5561
new object[] { "FK_Note_Customer", "dbo", "Note", "CustomerId", "dbo", "Customer", "Id", 0 }
5662
);
5763
// ReSharper restore CoVariantArrayConversion
@@ -232,6 +238,22 @@ public void CustomerWithOrdersAndNotes()
232238
GeneratedSqlIs(expectedSql);
233239
}
234240

241+
[Test]
242+
public void CustomerWithOrdersWithItems()
243+
{
244+
const string expectedSql = "select [dbo].[Customer].[Id],[dbo].[Customer].[Name]," +
245+
"[dbo].[Order].[Id] AS [__withn__Orders__Id],[dbo].[Order].[CustomerId] AS [__withn__Orders__CustomerId]," +
246+
"[dbo].[Order].[Description] AS [__withn__Orders__Description],[dbo].[Item].[Id] AS [__withn__Items__Id]," +
247+
"[dbo].[Item].[OrderId] AS [__withn__Items__OrderId],[dbo].[Item].[Description] AS [__withn__Items__Description]" +
248+
" from [dbo].[Customer] LEFT JOIN [dbo].[Order] ON ([dbo].[Customer].[Id] = [dbo].[Order].[CustomerId])" +
249+
" LEFT JOIN [dbo].[Item] ON ([dbo].[Order].[Id] = [dbo].[Item].[OrderId])";
250+
251+
var q = _db.Customers.All().With(_db.Customers.Orders).With(_db.Customers.Orders.Items);
252+
EatException(() => q.ToList());
253+
254+
GeneratedSqlIs(expectedSql);
255+
}
256+
235257
/// <summary>
236258
/// Test for issue #157
237259
/// </summary>
Collapse file

‎Simple.Data.SqlTest/QueryTest.cs‎

Copy file name to clipboardExpand all lines: Simple.Data.SqlTest/QueryTest.cs
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,20 @@ public void FindAllWithClauseWithJoinCriteriaShouldPreselectDetailTableAsCollect
346346
Assert.AreEqual(1, orderItems.Count);
347347
}
348348

349+
[Test]
350+
public void FindAllWithClauseWithNestedDetailTable()
351+
{
352+
var db = DatabaseHelper.Open();
353+
var result = db.Customers.FindAllByCustomerId(1).With(db.Customers.Orders).With(db.Customers.Orders.OrderItems).FirstOrDefault() as IDictionary<string, object>;
354+
Assert.IsNotNull(result);
355+
Assert.Contains("Orders", (ICollection)result.Keys);
356+
var orders = result["Orders"] as IList<IDictionary<string, object>>;
357+
Assert.IsNotNull(orders);
358+
Assert.AreEqual(1, orders.Count);
359+
var order = orders[0];
360+
Assert.Contains("OrderItems", (ICollection)order.Keys);
361+
}
362+
349363
[Test]
350364
public void GetWithClauseWithJoinCriteriaShouldPreselectDetailTableAsCollection()
351365
{

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.