Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query API review changes #16706

Merged
merged 1 commit into from
Jul 23, 2019
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 8 additions & 8 deletions src/EFCore.Abstractions/DbFunctionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Microsoft.EntityFrameworkCore
public class DbFunctionAttribute : Attribute
#pragma warning restore CA1813 // Avoid unsealed attributes
{
private string _functionName;
private string _name;
private string _schema;

/// <summary>
Expand All @@ -30,28 +30,28 @@ public DbFunctionAttribute()
/// <summary>
/// Initializes a new instance of the <see cref="DbFunctionAttribute" /> class.
/// </summary>
/// <param name="functionName">The name of the function in the database.</param>
/// <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 functionName, [CanBeNull] string schema = null)
public DbFunctionAttribute([NotNull] string name, [CanBeNull] string schema = null)
{
Check.NotEmpty(functionName, nameof(functionName));
Check.NotEmpty(name, nameof(name));

_functionName = functionName;
_name = name;
_schema = schema;
}

/// <summary>
/// The name of the function in the database.
/// </summary>
public virtual string FunctionName
public virtual string Name
{
get => _functionName;
get => _name;
[param: NotNull]
set
{
Check.NotEmpty(value, nameof(value));

_functionName = value;
_name = value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Reflection;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Utilities;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Query.Pipeline;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Utilities;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Collections;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
using Microsoft.EntityFrameworkCore.Utilities;
Expand Down Expand Up @@ -37,13 +37,24 @@ public virtual void ProcessEntityTypeAdded(

var entityType = entityTypeBuilder.Metadata;
if (entityTypeBuilder.Metadata.BaseType == null
&& !entityTypeBuilder.Metadata.GetDerivedTypes().Any())
&& !Any(entityTypeBuilder.Metadata.GetDerivedTypes()))
{
entityTypeBuilder.HasDiscriminator(typeof(string))
.HasValue(entityType, entityType.ShortName());
}
}

private static bool Any([NotNull] IEnumerable source)
{
foreach (var _ in source)
{
return true;
}

return false;
}


/// <summary>
/// Called after the base type of an entity type changes.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/CaseExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Query;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public virtual SqlExpression Translate(IModel model, SqlExpression instance, Met
// arguments.Select(e => _sqlExpressionFactory.ApplyDefaultTypeMapping(e)).ToList())
// ?? _sqlExpressionFactory.Function(
// dbFunction.Schema,
// dbFunction.FunctionName,
// dbFunction.Name,
// arguments,
// method.ReturnType);
//}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
using Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Query.NavigationExpansion;
using Microsoft.EntityFrameworkCore.Query.Pipeline;
using Microsoft.EntityFrameworkCore.Storage;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
Expand Down Expand Up @@ -312,7 +309,7 @@ protected override Expression VisitNew(NewExpression newExpression)
}
else
{
var projectionMember = _projectionMembers.Peek().AddMember(newExpression.Members[i]);
var projectionMember = _projectionMembers.Peek().Append(newExpression.Members[i]);
_projectionMembers.Push(projectionMember);
newArguments[i] = Visit(newExpression.Arguments[i]);
if (newArguments[i] == null)
Expand Down Expand Up @@ -350,7 +347,7 @@ protected override Expression VisitMemberInit(MemberInitExpression memberInitExp
}
else
{
var projectionMember = _projectionMembers.Peek().AddMember(memberAssignment.Member);
var projectionMember = _projectionMembers.Peek().Append(memberAssignment.Member);
_projectionMembers.Push(projectionMember);

var visitedExpression = Visit(memberAssignment.Expression);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Query.Pipeline;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Storage;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query.Pipeline;
using Microsoft.EntityFrameworkCore.Query;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Conventions;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Query.NavigationExpansion;
using Microsoft.EntityFrameworkCore.Query.Pipeline;
using Microsoft.EntityFrameworkCore.Storage;
using Newtonsoft.Json.Linq;

Expand Down Expand Up @@ -75,7 +71,7 @@ protected override Expression VisitShapedQueryExpression(ShapedQueryExpression s
shaperBody = new JObjectInjectingExpressionVisitor()
.Visit(shaperBody);
shaperBody = InjectEntityMaterializers(shaperBody);
shaperBody = new CosmosProjectionBindingRemovingExpressionVisitor(selectExpression, jObjectParameter, TrackQueryResults)
shaperBody = new CosmosProjectionBindingRemovingExpressionVisitor(selectExpression, jObjectParameter, IsTracking)
.Visit(shaperBody);

var shaperLambda = Expression.Lambda(
Expand All @@ -84,7 +80,7 @@ protected override Expression VisitShapedQueryExpression(ShapedQueryExpression s
jObjectParameter);

return Expression.New(
(Async
(IsAsync
? typeof(AsyncQueryingEnumerable<>)
: typeof(QueryingEnumerable<>)).MakeGenericType(shaperLambda.ReturnType).GetConstructors()[0],
Expression.Convert(QueryCompilationContext.QueryContextParameter, typeof(CosmosQueryContext)),
Expand Down Expand Up @@ -951,7 +947,7 @@ public override Expression Visit(Expression expression)
? _sqlExpressionFactory.In(
(SqlExpression)Visit(inExpression.Item),
_sqlExpressionFactory.Constant(inValues, typeMapping),
inExpression.Negated)
inExpression.IsNegated)
: null;

var nullCheckExpression = hasNullValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Query.Pipeline;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Query.Expressions.Internal;
using Microsoft.EntityFrameworkCore.Query.Pipeline;
using Microsoft.EntityFrameworkCore.Query;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
using System.Linq.Expressions;
using System.Reflection;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query.Expressions.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Query;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
Expand Down
16 changes: 8 additions & 8 deletions src/EFCore.Cosmos/Query/Internal/InExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.Storage;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
Expand All @@ -26,7 +26,7 @@ public InExpression(SqlExpression item, bool negated, SqlExpression values, Core
: base(typeof(bool), typeMapping)
{
Item = item;
Negated = negated;
IsNegated = negated;
Values = values;
}

Expand All @@ -44,7 +44,7 @@ public InExpression(SqlExpression item, bool negated, SqlExpression values, Core
/// 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 bool Negated { get; }
public virtual bool IsNegated { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down Expand Up @@ -74,7 +74,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// 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 InExpression Negate() => new InExpression(Item, !Negated, Values, TypeMapping);
public virtual InExpression Negate() => new InExpression(Item, !IsNegated, Values, TypeMapping);

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -84,7 +84,7 @@ protected override Expression VisitChildren(ExpressionVisitor visitor)
/// </summary>
public virtual InExpression Update(SqlExpression item, SqlExpression values)
=> item != Item || values != Values
? new InExpression(item, Negated, values, TypeMapping)
? new InExpression(item, IsNegated, values, TypeMapping)
: this;

/// <summary>
Expand All @@ -96,7 +96,7 @@ public virtual InExpression Update(SqlExpression item, SqlExpression values)
public override void Print(ExpressionPrinter expressionPrinter)
{
expressionPrinter.Visit(Item);
expressionPrinter.StringBuilder.Append(Negated ? " NOT IN " : " IN ");
expressionPrinter.StringBuilder.Append(IsNegated ? " NOT IN " : " IN ");
expressionPrinter.StringBuilder.Append("(");
expressionPrinter.Visit(Values);
expressionPrinter.StringBuilder.Append(")");
Expand All @@ -117,7 +117,7 @@ public override bool Equals(object obj)
private bool Equals(InExpression inExpression)
=> base.Equals(inExpression)
&& Item.Equals(inExpression.Item)
&& Negated.Equals(inExpression.Negated)
&& IsNegated.Equals(inExpression.IsNegated)
&& (Values == null ? inExpression.Values == null : Values.Equals(inExpression.Values));

/// <summary>
Expand All @@ -126,6 +126,6 @@ private bool Equals(InExpression inExpression)
/// 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 override int GetHashCode() => HashCode.Combine(base.GetHashCode(), Item, Negated, Values);
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), Item, IsNegated, Values);
}
}
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/KeyAccessExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Query;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
Expand Down
3 changes: 1 addition & 2 deletions src/EFCore.Cosmos/Query/Internal/ObjectAccessExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
using System;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query.Expressions.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Query;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
using System.Collections.Generic;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Query.Expressions.Internal;
using Microsoft.EntityFrameworkCore.Query.Internal;
using Microsoft.EntityFrameworkCore.Query;

namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal
{
Expand Down
Loading