forked from dotnet/efcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrossApplyExpression.cs
71 lines (61 loc) · 2.62 KB
/
CrossApplyExpression.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 a CROSS 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 CrossApplyExpression : JoinExpressionBase
{
/// <summary>
/// Creates a new instance of the <see cref="CrossApplyExpression" /> class.
/// </summary>
/// <param name="table">A table source to CROSS APPLY with.</param>
public CrossApplyExpression(TableExpressionBase table)
: this(table, annotations: null)
{
}
private CrossApplyExpression(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 CrossApplyExpression Update(TableExpressionBase table)
=> table != Table
? new CrossApplyExpression(table, GetAnnotations())
: this;
/// <inheritdoc />
protected override TableExpressionBase CreateWithAnnotations(IEnumerable<IAnnotation> annotations)
=> new CrossApplyExpression(Table, GetAnnotations());
/// <inheritdoc />
protected override void Print(ExpressionPrinter expressionPrinter)
{
expressionPrinter.Append("CROSS APPLY ");
expressionPrinter.Visit(Table);
PrintAnnotations(expressionPrinter);
}
/// <inheritdoc />
public override bool Equals(object? obj)
=> obj != null
&& (ReferenceEquals(this, obj)
|| obj is CrossApplyExpression crossApplyExpression
&& Equals(crossApplyExpression));
private bool Equals(CrossApplyExpression crossApplyExpression)
=> base.Equals(crossApplyExpression);
/// <inheritdoc />
public override int GetHashCode()
=> base.GetHashCode();
}