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 2c4d325
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/EFCore.Design/Query/Internal/QueryLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ private bool IsQueryable(ExpressionSyntax expression)
return false;

default:
Console.WriteLine($"Unexpected symbol type '{symbol.GetType().Name} for symbol '{symbol}' for query: " + expression);
// Console.WriteLine($"Unexpected symbol type '{symbol.GetType().Name}' for symbol '{symbol}' for query: " + expression);
return false;
}
}
Expand Down
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 2c4d325

Please sign in to comment.