Skip to content

Commit

Permalink
Query: Improve detection of non-composed FromSql
Browse files Browse the repository at this point in the history
Resolves #16079
  • Loading branch information
smitpatel committed Mar 20, 2020
1 parent 7166201 commit 2e6f04f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ public bool IsNonComposedFromSql()
&& Tables[0] is FromSqlExpression fromSql
&& Projection.All(
pe => pe.Expression is ColumnExpression column
&& string.Equals(fromSql.Alias, column.Table.Alias, StringComparison.OrdinalIgnoreCase));
&& string.Equals(fromSql.Alias, column.Table.Alias, StringComparison.OrdinalIgnoreCase))
&& _projectionMapping.TryGetValue(new ProjectionMember(), out var mapping)
&& mapping.Type == typeof(Dictionary<IProperty, int>);

public void ApplyProjection()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,15 +396,14 @@ public override void FromSqlRaw_queryable_simple_projection_composed()
{
base.FromSqlRaw_queryable_simple_projection_composed();

// issue #16079
// AssertSql(
// @"SELECT [p].[ProductName]
//FROM (
// SELECT *
// FROM ""Products""
// WHERE ""Discontinued"" <> CAST(1 AS bit)
// AND ((""UnitsInStock"" + ""UnitsOnOrder"") < ""ReorderLevel"")
//) AS [p]");
AssertSql(
@"SELECT [p].[ProductName]
FROM (
SELECT *
FROM ""Products""
WHERE ""Discontinued"" <> CAST(1 AS bit)
AND ((""UnitsInStock"" + ""UnitsOnOrder"") < ""ReorderLevel"")
) AS [p]");
}

public override void FromSqlRaw_queryable_simple_include()
Expand Down

0 comments on commit 2e6f04f

Please sign in to comment.