Skip to content

Commit

Permalink
Friendly names for lifted constant variables
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Jan 4, 2023
1 parent 44711b4 commit 9aba51f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ when GetProjectionIndex(collectionResultExpression.ProjectionBindingExpression)
// Expression.Constant(navigation),
_parentVisitor.Dependencies.LiftableConstantFactory.CreateLiftableConstant(
c => c.Dependencies.Model.FindEntityType(navigation.DeclaringEntityType.Name)!.FindNavigation(navigation.Name)!,
"navigation",
navigation.Name + "Navigation",
typeof(INavigationBase)),
// Expression.Constant(navigation.IsShadowProperty()
// ? null
Expand All @@ -717,7 +717,7 @@ when GetProjectionIndex(collectionResultExpression.ProjectionBindingExpression)
: _parentVisitor.Dependencies.LiftableConstantFactory.CreateLiftableConstant(
c => c.Dependencies.Model.FindEntityType(navigation.DeclaringEntityType.Name)!.FindNavigation(navigation.Name)!
.GetCollectionAccessor()!,
"navigationCollectionAccessor",
navigation.Name + "NavigationCollectionAccessor",
typeof(IClrCollectionAccessor)),
Expression.Constant(_isTracking),
#pragma warning disable EF1001 // Internal EF Core API usage.
Expand Down Expand Up @@ -755,7 +755,7 @@ inverseNavigation is null
? Expression.Constant(null, typeof(INavigationBase))
: _parentVisitor.Dependencies.LiftableConstantFactory.CreateLiftableConstant(
c => c.Dependencies.Model.FindEntityType(inverseNavigation.DeclaringEntityType.Name)!.FindNavigation(navigation.Name)!,
"inverseNavigation",
navigation.Name + "InverseNavigation",
typeof(INavigationBase)),
GenerateFixup(includingEntityClrType, relatedEntityClrType, navigation, inverseNavigation),
Expression.Constant(_isTracking)));
Expand Down Expand Up @@ -813,13 +813,13 @@ inverseNavigation is null
// Expression.Constant(navigation),
_parentVisitor.Dependencies.LiftableConstantFactory.CreateLiftableConstant(
c => c.Dependencies.Model.FindEntityType(navigation.DeclaringEntityType.Name)!.FindNavigation(navigation.Name)!,
"navigation",
navigation.Name + "Navigation",
typeof(INavigationBase)),
// Expression.Constant(navigation.GetCollectionAccessor()),
_parentVisitor.Dependencies.LiftableConstantFactory.CreateLiftableConstant(
c => c.Dependencies.Model.FindEntityType(navigation.DeclaringEntityType.Name)!.FindNavigation(navigation.Name)!
.GetCollectionAccessor()!,
"navigationCollectionAccessor",
navigation.Name + "NavigationCollectionAccessor",
typeof(IClrCollectionAccessor)),
Expression.Constant(_isTracking),
#pragma warning disable EF1001 // Internal EF Core API usage.
Expand Down Expand Up @@ -860,7 +860,7 @@ inverseNavigation is null
? Expression.Constant(null, typeof(INavigationBase))
: _parentVisitor.Dependencies.LiftableConstantFactory.CreateLiftableConstant(
c => c.Dependencies.Model.FindEntityType(inverseNavigation.DeclaringEntityType.Name)!.FindNavigation(navigation.Name)!,
"inverseNavigation",
navigation.Name + "InverseNavigation",
typeof(INavigationBase)),
GenerateFixup(includingEntityClrType, relatedEntityClrType, navigation, inverseNavigation),
Expression.Constant(_isTracking)));
Expand Down Expand Up @@ -1616,7 +1616,7 @@ private Expression AddToCollectionNavigation(
_parentVisitor.Dependencies.LiftableConstantFactory.CreateLiftableConstant(
c => c.Dependencies.Model.FindEntityType(navigation.DeclaringEntityType.Name)!.FindNavigation(navigation.Name)!
.GetCollectionAccessor()!,
"navigationCollectionAccessor",
navigation.Name + "NavigationCollectionAccessor",
typeof(IClrCollectionAccessor)),

CollectionAccessorAddMethodInfo,
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/Query/LiftableConstantExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public LiftableConstantExpression(
Type type)
{
ResolverExpression = resolverExpression;
VariableName = variableName;
VariableName = char.ToLower(variableName[0]) + variableName[1..];
Type = type;
}

Expand Down
6 changes: 3 additions & 3 deletions src/EFCore/Query/ShapedQueryCompilingExpressionVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ private Expression ProcessEntityShaper(EntityShaperExpression entityShaperExpres
_liftableConstantFactory.CreateLiftableConstant(
// TODO: Owned, STET
c => c.Dependencies.Model.FindEntityType(entityType.Name)!.FindPrimaryKey()!,
"key",
entityType.Name + "Key",
typeof(IKey)),
// Expression.Constant(primaryKey),
Expression.NewArrayInit(
Expand Down Expand Up @@ -546,7 +546,7 @@ private Expression MaterializeEntity(
{
materializationConditionBody = _liftableConstantFactory.CreateLiftableConstant(
c => c.Dependencies.Model.FindEntityType(materializedEntityType.Name)!,
"entityType",
materializedEntityType.Name + "EntityType",
typeof(IEntityType));
}

Expand All @@ -566,7 +566,7 @@ private Expression MaterializeEntity(
// Expression.Constant(concreteEntityTypes[i], typeof(IEntityType))
_liftableConstantFactory.CreateLiftableConstant(
c => c.Dependencies.Model.FindEntityType(concreteEntityType.Name)!,
"entityType",
concreteEntityType.Name + "EntityType",
typeof(IEntityType)));
}

Expand Down

0 comments on commit 9aba51f

Please sign in to comment.