Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/EFCore.Cosmos/Extensions/CosmosDbFunctionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public static double FullTextScore(this DbFunctions _, string property, params s
/// Combines scores provided by two or more specified functions.
/// </summary>
/// <param name="_">The <see cref="DbFunctions" /> instance.</param>
/// <param name="functions">The functions to compute the score for.</param>
/// <param name="scores">Scoring function calls to be combined.</param>
/// <returns>The combined score.</returns>
public static double Rrf(this DbFunctions _, params double[] functions)
public static double Rrf(this DbFunctions _, params double[] scores)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Rrf)));

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore.Cosmos.Internal;
using Microsoft.EntityFrameworkCore.Internal;
using static Microsoft.EntityFrameworkCore.Query.QueryHelpers;
using static Microsoft.EntityFrameworkCore.Infrastructure.ExpressionExtensions;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;

namespace Microsoft.EntityFrameworkCore.Query;
Expand Down Expand Up @@ -189,4 +190,14 @@ protected virtual bool IsValidSelectExpressionForExecuteDelete(SelectExpression
GroupBy: [],
Having: null
};

/// <summary>
/// This method has been obsoleted, use the method accepting a single SelectExpression parameter instead.
/// </summary>
[Obsolete("This method has been obsoleted, use the method accepting a single SelectExpression parameter instead.", error: true)]
protected virtual bool IsValidSelectExpressionForExecuteDelete(
SelectExpression selectExpression,
StructuralTypeShaperExpression shaper,
[NotNullWhen(true)] out TableExpression? tableExpression)
=> throw new UnreachableException();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
using static Microsoft.EntityFrameworkCore.Query.QueryHelpers;
using static Microsoft.EntityFrameworkCore.Infrastructure.ExpressionExtensions;

namespace Microsoft.EntityFrameworkCore.Query;

Expand Down
51 changes: 51 additions & 0 deletions src/EFCore/Infrastructure/ExpressionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,55 @@ static Expression AddConvertToObject(Expression expression)
? Expression.Convert(expression, typeof(object))
: expression;
}

/// <summary>
/// Returns whether the given expression represents a member access and if so, returns the decomposed base expression and the member
/// identity.
/// </summary>
/// <param name="expression">The expression to check.</param>
/// <param name="model">The model being used.</param>
/// <param name="baseExpression">The given expression, with the top-level member access node removed.</param>
/// <returns>
/// <see langword="true" /> if <paramref name="expression"/> represents a member access, <see langword="false" /> otherwise.
/// </returns>
public static bool IsMemberAccess(
Expression expression,
IModel model,
[NotNullWhen(true)] out Expression? baseExpression)
=> IsMemberAccess(expression, model, out baseExpression, out _);

/// <summary>
/// Returns whether the given expression represents a member access and if so, returns the decomposed base expression and the member
/// identity.
/// </summary>
/// <param name="expression">The expression to check.</param>
/// <param name="model">The model being used.</param>
/// <param name="baseExpression">The given expression, with the top-level member access node removed.</param>
/// <param name="memberIdentity">A <see cref="MemberIdentity" /> representing the member being accessed.</param>
/// <returns>
/// <see langword="true" /> if <paramref name="expression"/> represents a member access, <see langword="false" /> otherwise.
/// </returns>
public static bool IsMemberAccess(
Expression expression,
IModel model,
[NotNullWhen(true)] out Expression? baseExpression,
out MemberIdentity memberIdentity)
{
switch (expression)
{
case MemberExpression { Expression: not null } member:
baseExpression = member.Expression;
memberIdentity = MemberIdentity.Create(member.Member);
return true;
case MethodCallExpression methodCall
when methodCall.TryGetEFPropertyArguments(out baseExpression, out var propertyName)
|| methodCall.TryGetIndexerArguments(model, out baseExpression, out propertyName):
memberIdentity = MemberIdentity.Create(propertyName);
return true;
default:
memberIdentity = MemberIdentity.None;
baseExpression = null;
return false;
}
}
}
36 changes: 36 additions & 0 deletions src/EFCore/Query/ParameterQueryRootExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,40 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// <inheritdoc />
protected override void Print(ExpressionPrinter expressionPrinter)
=> expressionPrinter.Visit(QueryParameterExpression);

/// <summary>
/// This constructor has been obsoleted, use the constructor accepting QueryParameterExpression instead.
/// </summary>
[Obsolete("Use the constructor accepting QueryParameterExpression instead.")]
public ParameterQueryRootExpression(
IAsyncQueryProvider asyncQueryProvider,
Type elementType,
ParameterExpression parameterExpression)
: this(
asyncQueryProvider,
elementType,
new QueryParameterExpression(
parameterExpression.Name ?? throw new ArgumentException($"{parameterExpression} must have a name"),
parameterExpression.Type))
{
}

/// <summary>
/// This constructor has been obsoleted, use the constructor accepting QueryParameterExpression instead.
/// </summary>
[Obsolete("Use the constructor accepting QueryParameterExpression instead.")]
public ParameterQueryRootExpression(Type elementType, ParameterExpression parameterExpression)
: this(
elementType,
new QueryParameterExpression(
parameterExpression.Name ?? throw new ArgumentException($"{parameterExpression} must have a name"),
parameterExpression.Type))
{
}

/// <summary>
/// This constructor has been obsoleted, use QueryParameterExpression instead.
/// </summary>
[Obsolete("Use QueryParameterExpression instead.")]
public virtual ParameterExpression ParameterExpression => Parameter(QueryParameterExpression.Type, QueryParameterExpression.Name);
}
63 changes: 0 additions & 63 deletions src/EFCore/Query/QueryHelpers.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using static Microsoft.EntityFrameworkCore.Query.QueryHelpers;
using static Microsoft.EntityFrameworkCore.Infrastructure.ExpressionExtensions;

namespace Microsoft.EntityFrameworkCore.Query;

Expand Down