-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
4,074 additions
and
1,327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/EFCore.Relational/Query/ExpressionVisitors/Internal/GroupingShaper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// 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; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using System.Reflection; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Remotion.Linq.Clauses.ResultOperators; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.Internal | ||
{ | ||
/// <summary> | ||
/// This API supports the Entity Framework Core infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public class GroupingShaper : Shaper, IShaper<IGrouping<ValueBuffer, ValueBuffer>> | ||
{ | ||
/// <summary> | ||
/// This API supports the Entity Framework Core infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public GroupingShaper([NotNull] GroupResultOperator groupResultOperator) | ||
: base(groupResultOperator) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// This API supports the Entity Framework Core infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public override Type Type => typeof(IGrouping<ValueBuffer, ValueBuffer>); | ||
|
||
/// <summary> | ||
/// This API supports the Entity Framework Core infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public virtual IGrouping<ValueBuffer, ValueBuffer> Shape(QueryContext queryContext, ValueBuffer valueBuffer) | ||
{ | ||
return new ValueBufferGrouping(valueBuffer); | ||
} | ||
|
||
/// <summary> | ||
/// This API supports the Entity Framework Core infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public override Shaper WithOffset(int offset) => this; | ||
|
||
/// <summary> | ||
/// This API supports the Entity Framework Core infrastructure and is not intended to be used | ||
/// directly from your code. This API may change or be removed in future releases. | ||
/// </summary> | ||
public static Expression CreateValueBufferAccessExpression( | ||
[NotNull] Expression valueBufferGroupingExpression) | ||
{ | ||
return Expression.MakeMemberAccess( | ||
Expression.Convert( | ||
valueBufferGroupingExpression, | ||
typeof(ValueBufferGrouping)), | ||
_valueBufferGroupingValueBufferProperty); | ||
} | ||
|
||
private static readonly PropertyInfo _valueBufferGroupingValueBufferProperty | ||
= typeof(ValueBufferGrouping).GetTypeInfo().GetDeclaredProperty("ValueBuffer"); | ||
|
||
private struct ValueBufferGrouping : IGrouping<ValueBuffer, ValueBuffer> | ||
{ | ||
public ValueBufferGrouping(ValueBuffer valueBuffer) | ||
{ | ||
ValueBuffer = valueBuffer; | ||
} | ||
|
||
public ValueBuffer ValueBuffer { get; } | ||
|
||
public ValueBuffer Key => ValueBuffer; | ||
|
||
public IEnumerator<ValueBuffer> GetEnumerator() => Enumerable.Repeat(ValueBuffer, 1).GetEnumerator(); | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.