Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public FromSqlQueryCosmosTest(
: base(fixture)
{
ClearLog();
Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}

protected NorthwindContext CreateContext()
Expand Down
47 changes: 28 additions & 19 deletions test/EFCore.Specification.Tests/Query/NorthwindJoinQueryTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -799,26 +799,35 @@ public virtual Task SelectMany_with_client_eval_with_constructor(bool async)
.OrderBy(c => c.CustomerID)
.Select(
c => new CustomerViewModel(
c.CustomerID, c.City,
c.CustomerID,
c.City,
c.Orders.SelectMany(
o => o.OrderDetails
.Where(od => od.OrderID < 11000)
.Select(od => new OrderDetailViewModel(od.OrderID, od.ProductID)))
.ToArray())),
assertOrder: true);
assertOrder: true,
elementAsserter: (e, a) =>
{
Assert.Equal(e.CustomerID, a.CustomerID);
Assert.Equal(e.City, a.City);
Assert.Equal(
e.Views.OrderBy(od => od.OrderID).ThenBy(od => od.ProductID),
a.Views.OrderBy(od => od.OrderID).ThenBy(od => od.ProductID));
});
}

private class CustomerViewModel
{
private readonly string _customerID;
private readonly string _city;
private readonly OrderDetailViewModel[] _views;
public string CustomerID { get; }
public string City { get; }
public OrderDetailViewModel[] Views { get; }

public CustomerViewModel(string customerID, string city, OrderDetailViewModel[] views)
{
_customerID = customerID;
_city = city;
_views = views;
CustomerID = customerID;
City = city;
Views = views;
}

public override bool Equals(object obj)
Expand All @@ -834,23 +843,23 @@ public override bool Equals(object obj)
}

private bool Equals(CustomerViewModel customerViewModel)
=> _customerID == customerViewModel._customerID
&& _city == customerViewModel._city
&& _views.SequenceEqual(customerViewModel._views);
=> CustomerID == customerViewModel.CustomerID
&& City == customerViewModel.City
&& Views.SequenceEqual(customerViewModel.Views);

public override int GetHashCode()
=> HashCode.Combine(_customerID, _city);
=> HashCode.Combine(CustomerID, City);
}

private class OrderDetailViewModel
{
private readonly int _orderID;
private readonly int _productID;
public int OrderID { get; }
public int ProductID { get; }

public OrderDetailViewModel(int orderID, int productID)
{
_orderID = orderID;
_productID = productID;
OrderID = orderID;
ProductID = productID;
}

public override bool Equals(object obj)
Expand All @@ -866,11 +875,11 @@ public override bool Equals(object obj)
}

private bool Equals(OrderDetailViewModel orderDetailViewModel)
=> _orderID == orderDetailViewModel._orderID
&& _productID == orderDetailViewModel._productID;
=> OrderID == orderDetailViewModel.OrderID
&& ProductID == orderDetailViewModel.ProductID;

public override int GetHashCode()
=> HashCode.Combine(_orderID, _productID);
=> HashCode.Combine(OrderID, ProductID);
}

[ConditionalTheory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,7 @@ public virtual Task Where_collection_navigation_ToList_Contains(bool async)
return AssertQuery(
async,
ss => ss.Set<Customer>()
.Select(c => c.Orders.ToList())
.Select(c => c.Orders.OrderBy(o => o.OrderID).ToList())
.Where(e => e.Contains(order)),
entryCount: 5);
}
Expand Down Expand Up @@ -2251,7 +2251,7 @@ public virtual Task Where_collection_navigation_ToArray_Contains(bool async)
return AssertQuery(
async,
ss => ss.Set<Customer>()
.Select(c => c.Orders.AsEnumerable().ToArray())
.Select(c => c.Orders.AsEnumerable().OrderBy(o => o.OrderID).ToArray())
.Where(e => e.Contains(order)),
entryCount: 5);
}
Expand Down Expand Up @@ -2280,7 +2280,7 @@ public virtual Task Where_collection_navigation_AsEnumerable_Contains(bool async
return AssertQuery(
async,
ss => ss.Set<Customer>()
.Select(c => c.Orders.AsEnumerable())
.Select(c => c.Orders.OrderBy(o => o.OrderID).AsEnumerable())
.Where(e => e.Contains(order)),
entryCount: 5);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public NorthwindFunctionsQuerySqlServerTest(
: base(fixture)
{
ClearLog();
Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}

protected override bool CanExecuteQueryString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public NorthwindWhereQuerySqlServerTest(
: base(fixture)
{
ClearLog();
Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}

protected override bool CanExecuteQueryString
Expand Down Expand Up @@ -1996,14 +1996,17 @@ public override async Task Where_collection_navigation_ToList_Contains(bool asyn
AssertSql(
@"@__entity_equality_order_0_OrderID='10248' (Nullable = true)

SELECT [c].[CustomerID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate]
SELECT [c].[CustomerID], [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate]
FROM [Customers] AS [c]
LEFT JOIN [Orders] AS [o0] ON [c].[CustomerID] = [o0].[CustomerID]
LEFT JOIN (
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this subquery join that appeared after adding OrderBy

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smitpatel let me know if you want to follow up on this, can open an issue.

SELECT [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate]
FROM [Orders] AS [o0]
) AS [t] ON [c].[CustomerID] = [t].[CustomerID]
WHERE EXISTS (
SELECT 1
FROM [Orders] AS [o]
WHERE ([c].[CustomerID] = [o].[CustomerID]) AND ([o].[OrderID] = @__entity_equality_order_0_OrderID))
ORDER BY [c].[CustomerID]");
ORDER BY [c].[CustomerID], [t].[OrderID]");
}

public override async Task Where_collection_navigation_ToArray_Count(bool async)
Expand All @@ -2028,14 +2031,17 @@ public override async Task Where_collection_navigation_ToArray_Contains(bool asy
AssertSql(
@"@__entity_equality_order_0_OrderID='10248' (Nullable = true)

SELECT [c].[CustomerID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate]
SELECT [c].[CustomerID], [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate]
FROM [Customers] AS [c]
LEFT JOIN [Orders] AS [o0] ON [c].[CustomerID] = [o0].[CustomerID]
LEFT JOIN (
SELECT [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate]
FROM [Orders] AS [o0]
) AS [t] ON [c].[CustomerID] = [t].[CustomerID]
WHERE EXISTS (
SELECT 1
FROM [Orders] AS [o]
WHERE ([c].[CustomerID] = [o].[CustomerID]) AND ([o].[OrderID] = @__entity_equality_order_0_OrderID))
ORDER BY [c].[CustomerID]");
ORDER BY [c].[CustomerID], [t].[OrderID]");
}

public override async Task Where_collection_navigation_AsEnumerable_Count(bool async)
Expand All @@ -2060,14 +2066,17 @@ public override async Task Where_collection_navigation_AsEnumerable_Contains(boo
AssertSql(
@"@__entity_equality_order_0_OrderID='10248' (Nullable = true)

SELECT [c].[CustomerID], [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate]
SELECT [c].[CustomerID], [t].[OrderID], [t].[CustomerID], [t].[EmployeeID], [t].[OrderDate]
FROM [Customers] AS [c]
LEFT JOIN [Orders] AS [o0] ON [c].[CustomerID] = [o0].[CustomerID]
LEFT JOIN (
SELECT [o0].[OrderID], [o0].[CustomerID], [o0].[EmployeeID], [o0].[OrderDate]
FROM [Orders] AS [o0]
) AS [t] ON [c].[CustomerID] = [t].[CustomerID]
WHERE EXISTS (
SELECT 1
FROM [Orders] AS [o]
WHERE ([c].[CustomerID] = [o].[CustomerID]) AND ([o].[OrderID] = @__entity_equality_order_0_OrderID))
ORDER BY [c].[CustomerID]");
ORDER BY [c].[CustomerID], [t].[OrderID]");
}

public override async Task Where_collection_navigation_ToList_Count_member(bool async)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class OwnedQuerySqlServerTest : OwnedQueryRelationalTestBase<OwnedQuerySq
public OwnedQuerySqlServerTest(OwnedQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper)
: base(fixture)
{
Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}

protected override bool CanExecuteQueryString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class FromSqlQuerySqliteTest : FromSqlQueryTestBase<NorthwindQuerySqliteF
public FromSqlQuerySqliteTest(NorthwindQuerySqliteFixture<NoopModelCustomizer> fixture, ITestOutputHelper testOutputHelper)
: base(fixture)
{
fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
//Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
}

public override async Task<string> FromSqlRaw_queryable_composed(bool async)
Expand Down