Repository navigation
Query: Include: Second part of new IncludeCompiler - Adds support for single level collection includes. - #7974
Conversation
anpete
commented
Mar 23, 2017
- Collection includes now built using QueryModel!
- Added Task "lifting" capability to core query Select/GroupBy operations enabling async projection, required when enumerating included collections asynchronously.
- Added family of Conditional -> Coalesce expression optimizations.
- Added ICloneableQueryAnnotation used to clone query annotations from Include outer QueryModel.
- Added AssertSql for easier SQL baseline updating.
8b9d24f to
200fd01
Compare
|
|
| .GetDeclaredMethod(nameof(_GroupByAsync)); | ||
|
|
||
| // ReSharper disable once InconsistentNaming | ||
| private static IAsyncEnumerable<IGrouping<TKey, TElement>> _GroupByAsync<TSource, TKey, TElement>( |
There was a problem hiding this comment.
Can we move these methods into a separate file or in AsyncLinqOperatorProvider ?
There was a problem hiding this comment.
@smitpatel @maumar These have no sync counterparts and so would prefer to keep them as impl. detail. I have been pondering using partials more for managing nested classes, thoughts?
| ) AS [t7] | ||
| ORDER BY [t6].[CustomerID] | ||
|
|
||
| SELECT [c2.Orders].[OrderID], [c2.Orders].[CustomerID], [c2.Orders].[EmployeeID], [c2.Orders].[OrderDate] |
There was a problem hiding this comment.
why do we issue this query?
There was a problem hiding this comment.
There are a few cases for complex queries where we generate worse queries after this change. Haven't looked deeply into it yet, but something is preventing full lifting for this query.
There was a problem hiding this comment.
should we file a bug to track this?
| { | ||
| // Converts '[q] != null ? [q] : [s]' into '[q] ?? [s]' | ||
|
|
||
| if (binaryExpression.NodeType == ExpressionType.NotEqual |
There was a problem hiding this comment.
For the whole block? If so, considered it but will take another look
|
|
||
| /// <summary> | ||
| /// This API supports the Entity Framework Core infrastructure and is not intended to be used | ||
| /// directly from your code. This API may change or be removed in future releases. |
There was a problem hiding this comment.
how is it different from base?
There was a problem hiding this comment.
Looks like some stale code, will remove.
| return identityMap.CreateIncludeKeyComparer(navigation, (ValueBuffer)boxedValueBuffer); | ||
| } | ||
|
|
||
| #region Legacy Include |
There was a problem hiding this comment.
do we still need legacy?
There was a problem hiding this comment.
For a little longer.
|
4 test failures in SqlServer.FunctionalTests |
| WHERE EXISTS ( | ||
| SELECT 1 | ||
| FROM [Gear] AS [g] | ||
| SELECT [g.Weapons].[Id], [g.Weapons].[AmmunitionType], [g.Weapons].[IsAutomatic], [g.Weapons].[Name], [g.Weapons].[OwnerFullName], [g.Weapons].[SynergyWithId] |
There was a problem hiding this comment.
consider adding a more complex scenario with coalesce
e.g.
var query = from g1 in context.Gears.Include(g => g.Weapons)
join g2 in context.Gears
on g1.LeaderNickname equals g2.Nickname into grouping
from g2 in grouping.DefaultIfEmpty()
join g3 in context.Gears
on g2.LeaderNickname equals g3.Nickname into grouping2
from g3 in grouping2.DefaultIfEmpty()
select g3 ?? g1 ?? g2;
it actually does work!
| /// This API supports the Entity Framework Core infrastructure and is not intended to be used | ||
| /// directly from your code. This API may change or be removed in future releases. | ||
| /// </summary> | ||
| public static bool IsIncludeMethod([NotNull] MethodCallExpression methodCallExpression) |
There was a problem hiding this comment.
DRY it up with MethodIsClosedFormOf, or u wanted to avoid the second methodCallExpression.Method.IsGenericMethod?
| return node; | ||
| } | ||
|
|
||
| return Expression.Lambda(newBody, node.Name, node.TailCall, newParameters); |
There was a problem hiding this comment.
node.Update doesn't work for some cases? (the default implementation from ExpressionVisitor)
There was a problem hiding this comment.
The lambda's type may change here, which Update does not allow.
|
|
||
| if (binaryExpression.NodeType == ExpressionType.NotEqual | ||
| && binaryExpression.Left is QuerySourceReferenceExpression querySourceReferenceExpression1 | ||
| && binaryExpression.Right.RemoveConvert() is ConstantExpression constantExpression1 |
There was a problem hiding this comment.
Could be worthwhile to create extension method IsNullConstantExpression, this pattern is used in other places also (e.g. member access binding, sql translating visitor). Unless we don't want extension on Expression (base type)
| } | ||
| = (queryModel.SelectClause.Selector as QuerySourceReferenceExpression)?.ReferencedQuerySource | ||
| ?? | ||
| // The selector may not have been a QSRE but this query model may still have something that needs adjusted. |
There was a problem hiding this comment.
nit: move the comment up, so that it's not in the middle of coalesce expression.
There was a problem hiding this comment.
But having block comment in the middle of binary operator is awesome! ![]()
200fd01 to
a0ce95d
Compare
… single level collection includes. - Collection includes now built using QueryModel! - Added Task "lifting" capability to core query Select/GroupBy operations enabling async projection, required when enumerating included collections asynchronously. - Added family of Conditional -> Coalesce expression optimizations. - Added ICloneableQueryAnnotation used to clone query annotations from Include outer QueryModel. - Added AssertSql for easier SQL baseline updating.
a0ce95d to
67b6733
Compare
|
Looking good, can't wait to try this out. Will this be scheduled for the 1.2.0 release and if so, what date is it expected to be released? |
|
@joacar - We don't have dates yet. If you want to try this out you can use our nightly builds. |