forked from dotnet/efcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOuterApplyExpression.cs
71 lines (61 loc) · 2.62 KB
/
OuterApplyExpression.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace Microsoft.EntityFrameworkCore.Query.SqlExpressions;
/// <summary>
/// <para>
/// An expression that represents an OUTER APPLY in a SQL tree.
/// </para>
/// <para>
/// This type is typically used by database providers (and other extensions). It is generally
/// not used in application code.
/// </para>
/// </summary>
public class OuterApplyExpression : JoinExpressionBase
{
/// <summary>
/// Creates a new instance of the <see cref="OuterApplyExpression" /> class.
/// </summary>
/// <param name="table">A table source to OUTER APPLY with.</param>
public OuterApplyExpression(TableExpressionBase table)
: this(table, annotations: null)
{
}
private OuterApplyExpression(TableExpressionBase table, IEnumerable<IAnnotation>? annotations)
: base(table, annotations)
{
}
/// <inheritdoc />
protected override Expression VisitChildren(ExpressionVisitor visitor)
=> Update((TableExpressionBase)visitor.Visit(Table));
/// <summary>
/// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will
/// return this expression.
/// </summary>
/// <param name="table">The <see cref="JoinExpressionBase.Table" /> property of the result.</param>
/// <returns>This expression if no children changed, or an expression with the updated children.</returns>
public override OuterApplyExpression Update(TableExpressionBase table)
=> table != Table
? new OuterApplyExpression(table, GetAnnotations())
: this;
/// <inheritdoc />
protected override TableExpressionBase CreateWithAnnotations(IEnumerable<IAnnotation> annotations)
=> new OuterApplyExpression(Table, annotations);
/// <inheritdoc />
protected override void Print(ExpressionPrinter expressionPrinter)
{
expressionPrinter.Append("OUTER APPLY ");
expressionPrinter.Visit(Table);
PrintAnnotations(expressionPrinter);
}
/// <inheritdoc />
public override bool Equals(object? obj)
=> obj != null
&& (ReferenceEquals(this, obj)
|| obj is OuterApplyExpression outerApplyExpression
&& Equals(outerApplyExpression));
private bool Equals(OuterApplyExpression outerApplyExpression)
=> base.Equals(outerApplyExpression);
/// <inheritdoc />
public override int GetHashCode()
=> base.GetHashCode();
}