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

Fix to #19023 - Query: Log query plan #19674

Merged
merged 1 commit into from
Feb 10, 2020
Merged
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
12 changes: 11 additions & 1 deletion src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Internal
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public class RelationalCommandCache
public class RelationalCommandCache : IPrintableExpression
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not great (at least the name). Alternative I can think of is adding back RelationalExpressionPrinter and some custom classes to print various types of objects wrapped inside ConstantExpression.

Adding interface to RelationalCommandCache seems like the lesser of 2 evils. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internal class, so doesn't matter that much

{
private static readonly ConcurrentDictionary<object, object> _syncObjects
= new ConcurrentDictionary<object, object>();
Expand Down Expand Up @@ -73,6 +73,16 @@ public virtual IRelationalCommand GetRelationalCommand([NotNull] IReadOnlyDictio
return relationalCommand;
}

public virtual void Print(ExpressionPrinter expressionPrinter)
{
expressionPrinter.AppendLine("RelationalCommandCache.SelectExpression(");
using (expressionPrinter.Indent())
{
expressionPrinter.Visit(_selectExpression);
expressionPrinter.Append(")");
}
}

private readonly struct CommandCacheKey
{
private readonly SelectExpression _selectExpression;
Expand Down