@@ -21,6 +21,7 @@ namespace Microsoft.EntityFrameworkCore.Query.SqlExpressions;
2121/// an issue at <see href="https://github.com/dotnet/efcore">github.com/dotnet/efcore</see>.
2222/// </remarks>
2323// Class is sealed because there are no public/protected constructors. Can be unsealed if this is changed.
24+ [ DebuggerDisplay ( "{PrintShortSql(), nq}" ) ]
2425public sealed partial class SelectExpression : TableExpressionBase
2526{
2627 private const string DiscriminatorColumnAlias = "Discriminator" ;
@@ -4561,6 +4562,13 @@ public override IEnumerable<IAnnotation> GetAnnotations()
45614562
45624563 /// <inheritdoc />
45634564 protected override void Print ( ExpressionPrinter expressionPrinter )
4565+ {
4566+ PrintProjections ( expressionPrinter ) ;
4567+ expressionPrinter . AppendLine ( ) ;
4568+ PrintSql ( expressionPrinter ) ;
4569+ }
4570+
4571+ private void PrintProjections ( ExpressionPrinter expressionPrinter )
45644572 {
45654573 if ( _clientProjections . Count > 0 )
45664574 {
@@ -4588,12 +4596,16 @@ protected override void Print(ExpressionPrinter expressionPrinter)
45884596 }
45894597 }
45904598 }
4599+ }
45914600
4592- expressionPrinter . AppendLine ( ) ;
4593-
4594- foreach ( var tag in Tags )
4601+ private void PrintSql ( ExpressionPrinter expressionPrinter , bool withTags = true )
4602+ {
4603+ if ( withTags )
45954604 {
4596- expressionPrinter . Append ( $ "-- { tag } ") ;
4605+ foreach ( var tag in Tags )
4606+ {
4607+ expressionPrinter . Append ( $ "-- { tag } ") ;
4608+ }
45974609 }
45984610
45994611 IDisposable ? indent = null ;
@@ -4682,6 +4694,26 @@ protected override void Print(ExpressionPrinter expressionPrinter)
46824694 }
46834695 }
46844696
4697+ private string PrintShortSql ( )
4698+ {
4699+ var expressionPrinter = new ExpressionPrinter ( ) ;
4700+ PrintSql ( expressionPrinter , withTags : false ) ;
4701+ return expressionPrinter . ToString ( ) ;
4702+ }
4703+
4704+ /// <summary>
4705+ /// <para>
4706+ /// Expand this property in the debugger for a human-readable representation of this <see cref="SelectExpression" />.
4707+ /// </para>
4708+ /// <para>
4709+ /// Warning: Do not rely on the format of the debug strings.
4710+ /// They are designed for debugging only and may change arbitrarily between releases.
4711+ /// </para>
4712+ /// </summary>
4713+ [ EntityFrameworkInternal ]
4714+ public string DebugView
4715+ => this . Print ( ) ;
4716+
46854717 /// <inheritdoc />
46864718 public override bool Equals ( object ? obj )
46874719 => obj != null
0 commit comments