Skip to content

Commit 10cc40b

Browse files
committed
Address API review notes
1 parent bd1e532 commit 10cc40b

8 files changed

+103
-68
lines changed

src/EFCore.Cosmos/Extensions/CosmosDbFunctionsExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ public static double FullTextScore(this DbFunctions _, string property, params s
9494
/// Combines scores provided by two or more specified functions.
9595
/// </summary>
9696
/// <param name="_">The <see cref="DbFunctions" /> instance.</param>
97-
/// <param name="functions">The functions to compute the score for.</param>
97+
/// <param name="scores">Scoring function calls to be combined.</param>
9898
/// <returns>The combined score.</returns>
99-
public static double Rrf(this DbFunctions _, params double[] functions)
99+
public static double Rrf(this DbFunctions _, params double[] scores)
100100
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Rrf)));
101101

102102
/// <summary>

src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Diagnostics.CodeAnalysis;
66
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
77
using Microsoft.EntityFrameworkCore.Internal;
8-
using static Microsoft.EntityFrameworkCore.Query.QueryHelpers;
8+
using static Microsoft.EntityFrameworkCore.Infrastructure.ExpressionExtensions;
99

1010
namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;
1111

src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteDelete.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
45
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
56

67
namespace Microsoft.EntityFrameworkCore.Query;
@@ -189,4 +190,14 @@ protected virtual bool IsValidSelectExpressionForExecuteDelete(SelectExpression
189190
GroupBy: [],
190191
Having: null
191192
};
193+
194+
/// <summary>
195+
/// This method has been obsoleted, use the method accepting a single SelectExpression parameter instead.
196+
/// </summary>
197+
[Obsolete("This method has been obsoleted, use the method accepting a single SelectExpression parameter instead.", error: true)]
198+
protected virtual bool IsValidSelectExpressionForExecuteDelete(
199+
SelectExpression selectExpression,
200+
StructuralTypeShaperExpression shaper,
201+
[NotNullWhen(true)] out TableExpression? tableExpression)
202+
=> throw new UnreachableException();
192203
}

src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.ExecuteUpdate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Diagnostics.CodeAnalysis;
55
using Microsoft.EntityFrameworkCore.Query.Internal;
66
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
7-
using static Microsoft.EntityFrameworkCore.Query.QueryHelpers;
7+
using static Microsoft.EntityFrameworkCore.Infrastructure.ExpressionExtensions;
88

99
namespace Microsoft.EntityFrameworkCore.Query;
1010

src/EFCore/Infrastructure/ExpressionExtensions.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,4 +438,55 @@ static Expression AddConvertToObject(Expression expression)
438438
? Expression.Convert(expression, typeof(object))
439439
: expression;
440440
}
441+
442+
/// <summary>
443+
/// Returns whether the given expression represents a member access and if so, returns the decomposed base expression and the member
444+
/// identity.
445+
/// </summary>
446+
/// <param name="expression">The expression to check.</param>
447+
/// <param name="model">The model being used.</param>
448+
/// <param name="baseExpression">The given expression, with the top-level member access node removed.</param>
449+
/// <returns>
450+
/// <see langword="true" /> if <paramref name="expression"/> represents a member access, <see langword="false" /> otherwise.
451+
/// </returns>
452+
public static bool IsMemberAccess(
453+
Expression expression,
454+
IModel model,
455+
[NotNullWhen(true)] out Expression? baseExpression)
456+
=> IsMemberAccess(expression, model, out baseExpression, out _);
457+
458+
/// <summary>
459+
/// Returns whether the given expression represents a member access and if so, returns the decomposed base expression and the member
460+
/// identity.
461+
/// </summary>
462+
/// <param name="expression">The expression to check.</param>
463+
/// <param name="model">The model being used.</param>
464+
/// <param name="baseExpression">The given expression, with the top-level member access node removed.</param>
465+
/// <param name="memberIdentity">A <see cref="MemberIdentity" /> representing the member being accessed.</param>
466+
/// <returns>
467+
/// <see langword="true" /> if <paramref name="expression"/> represents a member access, <see langword="false" /> otherwise.
468+
/// </returns>
469+
public static bool IsMemberAccess(
470+
Expression expression,
471+
IModel model,
472+
[NotNullWhen(true)] out Expression? baseExpression,
473+
out MemberIdentity memberIdentity)
474+
{
475+
switch (expression)
476+
{
477+
case MemberExpression { Expression: not null } member:
478+
baseExpression = member.Expression;
479+
memberIdentity = MemberIdentity.Create(member.Member);
480+
return true;
481+
case MethodCallExpression methodCall
482+
when methodCall.TryGetEFPropertyArguments(out baseExpression, out var propertyName)
483+
|| methodCall.TryGetIndexerArguments(model, out baseExpression, out propertyName):
484+
memberIdentity = MemberIdentity.Create(propertyName);
485+
return true;
486+
default:
487+
memberIdentity = MemberIdentity.None;
488+
baseExpression = null;
489+
return false;
490+
}
491+
}
441492
}

src/EFCore/Query/ParameterQueryRootExpression.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,40 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
5858
/// <inheritdoc />
5959
protected override void Print(ExpressionPrinter expressionPrinter)
6060
=> expressionPrinter.Visit(QueryParameterExpression);
61+
62+
/// <summary>
63+
/// This constructor has been obsoleted, use the constructor accepting QueryParameterExpression instead.
64+
/// </summary>
65+
[Obsolete("Use the constructor accepting QueryParameterExpression instead.")]
66+
public ParameterQueryRootExpression(
67+
IAsyncQueryProvider asyncQueryProvider,
68+
Type elementType,
69+
ParameterExpression parameterExpression)
70+
: this(
71+
asyncQueryProvider,
72+
elementType,
73+
new QueryParameterExpression(
74+
parameterExpression.Name ?? throw new ArgumentException($"{parameterExpression} must have a name"),
75+
parameterExpression.Type))
76+
{
77+
}
78+
79+
/// <summary>
80+
/// This constructor has been obsoleted, use the constructor accepting QueryParameterExpression instead.
81+
/// </summary>
82+
[Obsolete("Use the constructor accepting QueryParameterExpression instead.")]
83+
public ParameterQueryRootExpression(Type elementType, ParameterExpression parameterExpression)
84+
: this(
85+
elementType,
86+
new QueryParameterExpression(
87+
parameterExpression.Name ?? throw new ArgumentException($"{parameterExpression} must have a name"),
88+
parameterExpression.Type))
89+
{
90+
}
91+
92+
/// <summary>
93+
/// This constructor has been obsoleted, use QueryParameterExpression instead.
94+
/// </summary>
95+
[Obsolete("Use QueryParameterExpression instead.")]
96+
public virtual ParameterExpression ParameterExpression => Parameter(QueryParameterExpression.Type, QueryParameterExpression.Name);
6197
}

src/EFCore/Query/QueryHelpers.cs

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/EFCore/Query/QueryableMethodTranslatingExpressionVisitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using static Microsoft.EntityFrameworkCore.Query.QueryHelpers;
4+
using static Microsoft.EntityFrameworkCore.Infrastructure.ExpressionExtensions;
55

66
namespace Microsoft.EntityFrameworkCore.Query;
77

0 commit comments

Comments
 (0)