Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for set operations over FromSql #18517

Merged
merged 1 commit into from
Oct 22, 2019
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 @@ -1040,6 +1040,20 @@ public virtual void Entity_equality_through_fromsql()
}
}

[ConditionalFact]
public virtual void FromSqlRaw_with_set_operation()
{
using var context = CreateContext();

var actual = context.Set<Customer>()
.FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = 'London'"))
.Concat(context.Set<Customer>()
.FromSqlRaw(NormalizeDelimetersInRawString("SELECT * FROM [Customers] WHERE [City] = 'Berlin'")))
.ToArray();

Assert.Equal(7, actual.Length);
}

protected string NormalizeDelimetersInRawString(string sql)
=> Fixture.TestStore.NormalizeDelimetersInRawString(sql);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,35 @@ public override void FromSqlRaw_does_not_parameterize_interpolated_string()
SELECT * FROM ""Orders"" WHERE ""OrderID"" < @p0");
}

public override void Entity_equality_through_fromsql()
{
base.Entity_equality_through_fromsql();

AssertSql(
@"SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate]
FROM (
SELECT * FROM ""Orders""
) AS [o]
LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID]
WHERE ([c].[CustomerID] = N'VINET') AND [c].[CustomerID] IS NOT NULL");
}

public override void FromSqlRaw_with_set_operation()
{
base.FromSqlRaw_with_set_operation();

AssertSql(
@"SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region]
FROM (
SELECT * FROM ""Customers"" WHERE ""City"" = 'London'
) AS [c]
UNION ALL
SELECT [c0].[CustomerID], [c0].[Address], [c0].[City], [c0].[CompanyName], [c0].[ContactName], [c0].[ContactTitle], [c0].[Country], [c0].[Fax], [c0].[Phone], [c0].[PostalCode], [c0].[Region]
FROM (
SELECT * FROM ""Customers"" WHERE ""City"" = 'Berlin'
) AS [c0]");
}

protected override DbParameter CreateDbParameter(string name, object value)
=> new SqlParameter { ParameterName = name, Value = value };

Expand Down