Skip to content

Commit d738dd3

Browse files
KenitoIncgathogojr
authored andcommitted
Restructure AggregationBinder
1 parent 8547df7 commit d738dd3

29 files changed

+4023
-509
lines changed

src/Microsoft.AspNetCore.OData/Abstracts/ContainerBuilderExtensions.cs

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public static IContainerBuilder AddDefaultWebApiServices(this IContainerBuilder
110110
builder.AddService<IFilterBinder, FilterBinder>(ServiceLifetime.Singleton);
111111
builder.AddService<IOrderByBinder, OrderByBinder>(ServiceLifetime.Singleton);
112112
builder.AddService<ISelectExpandBinder, SelectExpandBinder>(ServiceLifetime.Singleton);
113+
builder.AddService<IAggregationBinder, AggregationBinder>(ServiceLifetime.Singleton);
113114

114115
// HttpRequestScope.
115116
builder.AddService<HttpRequestScope>(ServiceLifetime.Scoped);

src/Microsoft.AspNetCore.OData/Common/TypeHelper.cs

+33
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,39 @@ public static bool IsDynamicTypeWrapper(this Type type)
4242

4343
public static bool IsComputeWrapper(this Type type, out Type entityType) => IsTypeWrapper(typeof(ComputeWrapper<>), type, out entityType);
4444

45+
public static bool IsFlatteningWrapper(this Type type)
46+
{
47+
if (type == null)
48+
{
49+
return false;
50+
}
51+
52+
if (type.IsGenericType)
53+
{
54+
Type genericTypeDefinition = type.GetGenericTypeDefinition();
55+
56+
if (!typeof(DynamicTypeWrapper).IsAssignableFrom(genericTypeDefinition))
57+
{
58+
return false;
59+
}
60+
61+
// Default implementation
62+
if (genericTypeDefinition == typeof(FlatteningWrapper<>))
63+
{
64+
return true;
65+
}
66+
67+
// Custom implementation
68+
PropertyInfo sourceProperty = genericTypeDefinition.GetProperty("Source");
69+
if (sourceProperty != null && sourceProperty.PropertyType == genericTypeDefinition.GetGenericArguments()[0])
70+
{
71+
return true;
72+
}
73+
}
74+
75+
return false;
76+
}
77+
4578
private static bool IsTypeWrapper(Type wrappedType, Type type, out Type entityType)
4679
{
4780
if (type == null)

src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.xml

+243-22
Large diffs are not rendered by default.

src/Microsoft.AspNetCore.OData/Properties/SRResources.Designer.cs

+13-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Microsoft.AspNetCore.OData/Properties/SRResources.resx

+3
Original file line numberDiff line numberDiff line change
@@ -748,4 +748,7 @@
748748
<data name="TypeMustBeOpenType" xml:space="preserve">
749749
<value>The type '{0}' must be an open type. The dynamic properties container property is only expected on open types.</value>
750750
</data>
751+
<data name="NotSupportedChildTransformationKind" xml:space="preserve">
752+
<value>Transformation kind '{0}' is not supported as a child transformation of kind '{1}'.</value>
753+
</data>
751754
</root>

src/Microsoft.AspNetCore.OData/PublicAPI.Unshipped.txt

+15
Original file line numberDiff line numberDiff line change
@@ -888,10 +888,16 @@ Microsoft.AspNetCore.OData.Query.ETag.this[string key].set -> void
888888
Microsoft.AspNetCore.OData.Query.ETag<TEntity>
889889
Microsoft.AspNetCore.OData.Query.ETag<TEntity>.ApplyTo(System.Linq.IQueryable<TEntity> query) -> System.Linq.IQueryable<TEntity>
890890
Microsoft.AspNetCore.OData.Query.ETag<TEntity>.ETag() -> void
891+
Microsoft.AspNetCore.OData.Query.Expressions.AggregationBinder
892+
Microsoft.AspNetCore.OData.Query.Expressions.AggregationBinder.AggregationBinder() -> void
891893
Microsoft.AspNetCore.OData.Query.Expressions.BinderExtensions
892894
Microsoft.AspNetCore.OData.Query.Expressions.ExpressionBinderBase
893895
Microsoft.AspNetCore.OData.Query.Expressions.FilterBinder
894896
Microsoft.AspNetCore.OData.Query.Expressions.FilterBinder.FilterBinder() -> void
897+
Microsoft.AspNetCore.OData.Query.Expressions.IAggregationBinder
898+
Microsoft.AspNetCore.OData.Query.Expressions.IAggregationBinder.BindGroupBy(Microsoft.OData.UriParser.Aggregation.TransformationNode transformationNode, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
899+
Microsoft.AspNetCore.OData.Query.Expressions.IAggregationBinder.BindSelect(Microsoft.OData.UriParser.Aggregation.TransformationNode transformationNode, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
900+
Microsoft.AspNetCore.OData.Query.Expressions.IAggregationBinder.FlattenReferencedProperties(Microsoft.OData.UriParser.Aggregation.TransformationNode transformationNode, System.Linq.IQueryable query, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context, out System.Linq.Expressions.ParameterExpression contextParameter, out System.Collections.Generic.IDictionary<Microsoft.OData.UriParser.SingleValueNode, System.Linq.Expressions.Expression> flattenedPropertiesMap) -> System.Linq.IQueryable
895901
Microsoft.AspNetCore.OData.Query.Expressions.IFilterBinder
896902
Microsoft.AspNetCore.OData.Query.Expressions.IFilterBinder.BindFilter(Microsoft.OData.UriParser.FilterClause filterClause, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
897903
Microsoft.AspNetCore.OData.Query.Expressions.IOrderByBinder
@@ -919,6 +925,7 @@ Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext.ComputedProperti
919925
Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext.CurrentParameter.get -> System.Linq.Expressions.ParameterExpression
920926
Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext.ElementClrType.get -> System.Type
921927
Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext.ElementType.get -> Microsoft.OData.Edm.IEdmType
928+
Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext.FlattenedPropertiesMap.get -> System.Collections.Generic.IDictionary<Microsoft.OData.UriParser.SingleValueNode, System.Linq.Expressions.Expression>
922929
Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext.GetParameter(string name) -> System.Linq.Expressions.ParameterExpression
923930
Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext.Model.get -> Microsoft.OData.Edm.IEdmModel
924931
Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext.NavigationSource.get -> Microsoft.OData.Edm.IEdmNavigationSource
@@ -929,6 +936,7 @@ Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext.QuerySettings.ge
929936
Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext.RemoveParameter(string name) -> void
930937
Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext.Source.get -> System.Linq.Expressions.Expression
931938
Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext.Source.set -> void
939+
Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext.TransformationElementType.get -> System.Type
932940
Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinder
933941
Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinder.FilterBinder.get -> Microsoft.AspNetCore.OData.Query.Expressions.IFilterBinder
934942
Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinder.OrderByBinder.get -> Microsoft.AspNetCore.OData.Query.Expressions.IOrderByBinder
@@ -1750,6 +1758,7 @@ static Microsoft.AspNetCore.OData.ODataServiceCollectionExtensions.AddODataQuery
17501758
static Microsoft.AspNetCore.OData.ODataUriFunctions.AddCustomUriFunction(string functionName, Microsoft.OData.UriParser.FunctionSignatureWithReturnType functionSignature, System.Reflection.MethodInfo methodInfo) -> void
17511759
static Microsoft.AspNetCore.OData.ODataUriFunctions.RemoveCustomUriFunction(string functionName, Microsoft.OData.UriParser.FunctionSignatureWithReturnType functionSignature, System.Reflection.MethodInfo methodInfo) -> bool
17521760
static Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.CreateErrorResponse(string message, System.Exception exception = null) -> Microsoft.AspNetCore.Mvc.SerializableError
1761+
static Microsoft.AspNetCore.OData.Query.Expressions.BinderExtensions.ApplyBind(this Microsoft.AspNetCore.OData.Query.Expressions.IAggregationBinder binder, System.Linq.IQueryable source, Microsoft.OData.UriParser.Aggregation.TransformationNode transformationNode, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context, out System.Type resultClrType) -> System.Linq.IQueryable
17531762
static Microsoft.AspNetCore.OData.Query.Expressions.BinderExtensions.ApplyBind(this Microsoft.AspNetCore.OData.Query.Expressions.IFilterBinder binder, System.Collections.IEnumerable query, Microsoft.OData.UriParser.FilterClause filterClause, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Collections.IEnumerable
17541763
static Microsoft.AspNetCore.OData.Query.Expressions.BinderExtensions.ApplyBind(this Microsoft.AspNetCore.OData.Query.Expressions.IFilterBinder binder, System.Linq.Expressions.Expression source, Microsoft.OData.UriParser.FilterClause filterClause, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
17551764
static Microsoft.AspNetCore.OData.Query.Expressions.BinderExtensions.ApplyBind(this Microsoft.AspNetCore.OData.Query.Expressions.IFilterBinder binder, System.Linq.IQueryable query, Microsoft.OData.UriParser.FilterClause filterClause, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.IQueryable
@@ -1761,6 +1770,7 @@ static Microsoft.AspNetCore.OData.Query.Expressions.BinderExtensions.ApplyBind(t
17611770
static Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.ApplyNullPropagationForFilterBody(System.Linq.Expressions.Expression body, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
17621771
static Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.GetDynamicPropertyContainer(Microsoft.OData.UriParser.CollectionOpenPropertyAccessNode openCollectionNode, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Reflection.PropertyInfo
17631772
static Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.GetDynamicPropertyContainer(Microsoft.OData.UriParser.SingleValueOpenPropertyAccessNode openNode, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Reflection.PropertyInfo
1773+
static Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.WrapConvert(System.Linq.Expressions.Expression expression) -> System.Linq.Expressions.Expression
17641774
static Microsoft.AspNetCore.OData.Query.HttpRequestODataQueryExtensions.GetETag(this Microsoft.AspNetCore.Http.HttpRequest request, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTagHeaderValue) -> Microsoft.AspNetCore.OData.Query.ETag
17651775
static Microsoft.AspNetCore.OData.Query.HttpRequestODataQueryExtensions.GetETag<TEntity>(this Microsoft.AspNetCore.Http.HttpRequest request, Microsoft.Net.Http.Headers.EntityTagHeaderValue entityTagHeaderValue) -> Microsoft.AspNetCore.OData.Query.ETag<TEntity>
17661776
static Microsoft.AspNetCore.OData.Query.ODataQueryOptions.IsSystemQueryOption(string queryOptionName) -> bool
@@ -1870,12 +1880,16 @@ virtual Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.CreateQueryOptions
18701880
virtual Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.GetModel(System.Type elementClrType, Microsoft.AspNetCore.Http.HttpRequest request, Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor) -> Microsoft.OData.Edm.IEdmModel
18711881
virtual Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.ValidateQuery(Microsoft.AspNetCore.Http.HttpRequest request, Microsoft.AspNetCore.OData.Query.ODataQueryOptions queryOptions) -> void
18721882
virtual Microsoft.AspNetCore.OData.Query.ETag.ApplyTo(System.Linq.IQueryable query) -> System.Linq.IQueryable
1883+
virtual Microsoft.AspNetCore.OData.Query.Expressions.AggregationBinder.BindGroupBy(Microsoft.OData.UriParser.Aggregation.TransformationNode transformationNode, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
1884+
virtual Microsoft.AspNetCore.OData.Query.Expressions.AggregationBinder.BindSelect(Microsoft.OData.UriParser.Aggregation.TransformationNode transformationNode, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
1885+
virtual Microsoft.AspNetCore.OData.Query.Expressions.AggregationBinder.FlattenReferencedProperties(Microsoft.OData.UriParser.Aggregation.TransformationNode transformationNode, System.Linq.IQueryable query, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context, out System.Linq.Expressions.ParameterExpression contextParameter, out System.Collections.Generic.IDictionary<Microsoft.OData.UriParser.SingleValueNode, System.Linq.Expressions.Expression> flattenedPropertiesMap) -> System.Linq.IQueryable
18731886
virtual Microsoft.AspNetCore.OData.Query.Expressions.ExpressionBinderBase.BindCollectionConstantNode(Microsoft.OData.UriParser.CollectionConstantNode node) -> System.Linq.Expressions.Expression
18741887
virtual Microsoft.AspNetCore.OData.Query.Expressions.ExpressionBinderBase.BindConstantNode(Microsoft.OData.UriParser.ConstantNode constantNode) -> System.Linq.Expressions.Expression
18751888
virtual Microsoft.AspNetCore.OData.Query.Expressions.ExpressionBinderBase.BindSingleValueFunctionCallNode(Microsoft.OData.UriParser.SingleValueFunctionCallNode node) -> System.Linq.Expressions.Expression
18761889
virtual Microsoft.AspNetCore.OData.Query.Expressions.FilterBinder.BindFilter(Microsoft.OData.UriParser.FilterClause filterClause, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
18771890
virtual Microsoft.AspNetCore.OData.Query.Expressions.OrderByBinder.BindOrderBy(Microsoft.OData.UriParser.OrderByClause orderByClause, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> Microsoft.AspNetCore.OData.Query.Expressions.OrderByBinderResult
18781891
virtual Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.Bind(Microsoft.OData.UriParser.QueryNode node, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
1892+
virtual Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.BindAccessExpression(Microsoft.OData.UriParser.QueryNode node, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context, System.Linq.Expressions.Expression baseElement = null) -> System.Linq.Expressions.Expression
18791893
virtual Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.BindAllNode(Microsoft.OData.UriParser.AllNode allNode, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
18801894
virtual Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.BindAnyNode(Microsoft.OData.UriParser.AnyNode anyNode, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
18811895
virtual Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.BindBinaryOperatorNode(Microsoft.OData.UriParser.BinaryOperatorNode binaryOperatorNode, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
@@ -1923,6 +1937,7 @@ virtual Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.BindToLower(Mic
19231937
virtual Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.BindToUpper(Microsoft.OData.UriParser.SingleValueFunctionCallNode node, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
19241938
virtual Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.BindTrim(Microsoft.OData.UriParser.SingleValueFunctionCallNode node, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
19251939
virtual Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.BindUnaryOperatorNode(Microsoft.OData.UriParser.UnaryOperatorNode unaryOperatorNode, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
1940+
virtual Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.CreateOpenPropertyAccessExpression(Microsoft.OData.UriParser.SingleValueOpenPropertyAccessNode openNode, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression
19261941
virtual Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinder.BindComputedProperty(System.Linq.Expressions.Expression source, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context, string computedProperty, System.Collections.Generic.IList<Microsoft.AspNetCore.OData.Query.Container.NamedPropertyExpression> includedProperties) -> void
19271942
virtual Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinder.BindOrderByProperties(Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context, System.Linq.Expressions.Expression source, Microsoft.OData.Edm.IEdmStructuredType structuredType, System.Collections.Generic.IList<Microsoft.AspNetCore.OData.Query.Container.NamedPropertyExpression> includedProperties, bool isSelectedAll) -> void
19281943
virtual Microsoft.AspNetCore.OData.Query.Expressions.SelectExpandBinder.BindSelectExpand(Microsoft.OData.UriParser.SelectExpandClause selectExpandClause, Microsoft.AspNetCore.OData.Query.Expressions.QueryBinderContext context) -> System.Linq.Expressions.Expression

0 commit comments

Comments
 (0)