Skip to content

Commit

Permalink
Another pass at query NRT (#23176)
Browse files Browse the repository at this point in the history
Part of #19007
  • Loading branch information
smitpatel committed Nov 3, 2020
1 parent 400fbb3 commit d5a3ebc
Show file tree
Hide file tree
Showing 68 changed files with 243 additions and 127 deletions.
12 changes: 7 additions & 5 deletions src/EFCore.Abstractions/DbFunctionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable enable

namespace Microsoft.EntityFrameworkCore
{
/// <summary>
Expand All @@ -17,8 +19,8 @@ namespace Microsoft.EntityFrameworkCore
public class DbFunctionAttribute : Attribute
#pragma warning restore CA1813 // Avoid unsealed attributes
{
private string _name;
private string _schema;
private string? _name;
private string? _schema;
private bool _builtIn;
private bool? _nullable;

Expand All @@ -34,7 +36,7 @@ public DbFunctionAttribute()
/// </summary>
/// <param name="name">The name of the function in the database.</param>
/// <param name="schema">The schema of the function in the database.</param>
public DbFunctionAttribute([NotNull] string name, [CanBeNull] string schema = null)
public DbFunctionAttribute([NotNull] string name, [CanBeNull] string? schema = null)
{
Check.NotEmpty(name, nameof(name));

Expand All @@ -45,7 +47,7 @@ public DbFunctionAttribute([NotNull] string name, [CanBeNull] string schema = nu
/// <summary>
/// The name of the function in the database.
/// </summary>
public virtual string Name
public virtual string? Name
{
get => _name;
[param: NotNull]
Expand All @@ -60,7 +62,7 @@ public virtual string Name
/// <summary>
/// The schema of the function in the database.
/// </summary>
public virtual string Schema
public virtual string? Schema
{
get => _schema;
[param: CanBeNull] set => _schema = value;
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore.Abstractions/Query/NotParameterizedAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using System;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Query
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions src/EFCore.Cosmos/Extensions/CosmosQueryableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable enable
// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

#nullable enable

// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore.Internal
{
Expand Down
7 changes: 5 additions & 2 deletions src/EFCore.Cosmos/Query/Internal/ContainsTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down Expand Up @@ -35,8 +37,8 @@ public ContainsTranslator([NotNull] ISqlExpressionFactory sqlExpressionFactory)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual SqlExpression Translate(
SqlExpression instance,
public virtual SqlExpression? Translate(
SqlExpression? instance,
MethodInfo method,
IReadOnlyList<SqlExpression> arguments,
IDiagnosticsLogger<DbLoggerCategory.Query> logger)
Expand All @@ -50,6 +52,7 @@ public virtual SqlExpression Translate(

if (arguments.Count == 1
&& method.IsContainsMethod()
&& instance != null
&& ValidateValues(instance))
{
return _sqlExpressionFactory.In(arguments[0], instance, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down Expand Up @@ -47,7 +49,7 @@ public CosmosMemberTranslatorProvider(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual SqlExpression Translate(
public virtual SqlExpression? Translate(
SqlExpression instance,
MemberInfo member,
Type returnType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down Expand Up @@ -53,9 +55,9 @@ public CosmosMethodCallTranslatorProvider(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual SqlExpression Translate(
public virtual SqlExpression? Translate(
IModel model,
SqlExpression instance,
SqlExpression? instance,
MethodInfo method,
IReadOnlyList<SqlExpression> arguments,
IDiagnosticsLogger<DbLoggerCategory.Query> logger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Query;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down Expand Up @@ -33,6 +35,6 @@ public CosmosQueryCompilationContext(
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual string PartitionKeyFromExtension { get; internal set; }
public virtual string? PartitionKeyFromExtension { get; internal set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Microsoft.EntityFrameworkCore.Utilities;
using Microsoft.Extensions.DependencyInjection;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
10 changes: 2 additions & 8 deletions src/EFCore.Cosmos/Query/Internal/CosmosQueryContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Microsoft.EntityFrameworkCore.Utilities;
using Microsoft.EntityFrameworkCore.ValueGeneration;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down Expand Up @@ -40,13 +42,5 @@ public CosmosQueryContext(
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual CosmosClientWrapper CosmosClient { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual IValueGeneratorSelector ValueGeneratorSelector { get; }
}
}
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/CosmosQueryContextFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Microsoft.EntityFrameworkCore.Utilities;
using Microsoft.Extensions.DependencyInjection;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Query;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Microsoft.EntityFrameworkCore.Utilities;
using Microsoft.Extensions.DependencyInjection;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Microsoft.EntityFrameworkCore.Utilities;
using Microsoft.Extensions.DependencyInjection;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down Expand Up @@ -105,8 +107,8 @@ private Expression VisitSqlConditional(SqlConditionalExpression sqlConditionalEx
private SqlExpression TryCompensateForBoolWithValueConverter(SqlExpression sqlExpression)
{
if (sqlExpression is KeyAccessExpression keyAccessExpression
&& keyAccessExpression.TypeMapping.ClrType == typeof(bool)
&& keyAccessExpression.TypeMapping.Converter != null)
&& keyAccessExpression.TypeMapping!.ClrType == typeof(bool)
&& keyAccessExpression.TypeMapping!.Converter != null)
{
return _sqlExpressionFactory.Equal(
sqlExpression,
Expand Down
10 changes: 6 additions & 4 deletions src/EFCore.Cosmos/Query/Internal/EqualsTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Utilities;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down Expand Up @@ -37,8 +39,8 @@ public EqualsTranslator([NotNull] ISqlExpressionFactory sqlExpressionFactory)
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual SqlExpression Translate(
SqlExpression instance,
public virtual SqlExpression? Translate(
SqlExpression? instance,
MethodInfo method,
IReadOnlyList<SqlExpression> arguments,
IDiagnosticsLogger<DbLoggerCategory.Query> logger)
Expand All @@ -47,8 +49,8 @@ public virtual SqlExpression Translate(
Check.NotNull(arguments, nameof(arguments));
Check.NotNull(logger, nameof(logger));

SqlExpression left = null;
SqlExpression right = null;
SqlExpression? left = null;
SqlExpression? right = null;

if (method.Name == nameof(object.Equals)
&& instance != null
Expand Down
4 changes: 3 additions & 1 deletion src/EFCore.Cosmos/Query/Internal/ExpressionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Storage;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand All @@ -21,7 +23,7 @@ public static class ExpressionExtensions
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public static CoreTypeMapping InferTypeMapping([NotNull] params Expression[] expressions)
public static CoreTypeMapping? InferTypeMapping([NotNull] params Expression[] expressions)
{
for (var i = 0; i < expressions.Length; i++)
{
Expand Down
4 changes: 3 additions & 1 deletion src/EFCore.Cosmos/Query/Internal/IMemberTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand All @@ -22,7 +24,7 @@ public interface IMemberTranslator
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
SqlExpression Translate(
SqlExpression? Translate(
[NotNull] SqlExpression instance,
[NotNull] MemberInfo member,
[NotNull] Type returnType,
Expand Down
2 changes: 2 additions & 0 deletions src/EFCore.Cosmos/Query/Internal/IMemberTranslatorPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using System.Collections.Generic;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand All @@ -22,7 +24,7 @@ public interface IMemberTranslatorProvider
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
SqlExpression Translate(
SqlExpression? Translate(
[NotNull] SqlExpression instance,
[NotNull] MemberInfo member,
[NotNull] Type returnType,
Expand Down
6 changes: 4 additions & 2 deletions src/EFCore.Cosmos/Query/Internal/IMethodCallTranslator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Diagnostics;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand All @@ -22,8 +24,8 @@ public interface IMethodCallTranslator
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
SqlExpression Translate(
[CanBeNull] SqlExpression instance,
SqlExpression? Translate(
[CanBeNull] SqlExpression? instance,
[NotNull] MethodInfo method,
[NotNull] IReadOnlyList<SqlExpression> arguments,
[NotNull] IDiagnosticsLogger<DbLoggerCategory.Query> logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using System.Collections.Generic;

#nullable enable

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
/// <summary>
Expand Down
Loading

0 comments on commit d5a3ebc

Please sign in to comment.