You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attempting to group-by and aggregate results in Expression Exception
Assemblies affected
Microsoft.AspNetCore.OData 8.0.12
Expected result
List of results
Actual result
Exception
Additional detail
Query: GET https://localhost:5041/odata/FutureCart?$apply=groupby((CatalogueId, ScheduledProvisioning/PartnerId, ScheduledProvisioning/State),aggregate(Quantity with sum as TotalQuantity))
Logged Exception:
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.ArgumentException: Instance property 'Values' is not defined for type 'System.Object' (Parameter 'propertyName')
at System.Linq.Expressions.Expression.Property(Expression expression, String propertyName)
at Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.GetPropertyExpression(Expression source, String propertyPath, Boolean isAggregated)
at Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.CreatePropertyAccessExpression(Expression source, QueryBinderContext context, IEdmProperty property, String propertyPath)
at Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.BindPropertyAccessQueryNode(SingleValuePropertyAccessNode propertyAccessNode, QueryBinderContext context)
at Microsoft.AspNetCore.OData.Query.Expressions.OrderByBinder.BindOrderBy(OrderByClause orderByClause, QueryBinderContext context)
at Microsoft.AspNetCore.OData.Query.Expressions.BinderExtensions.ApplyBind(IOrderByBinder binder, IQueryable query, OrderByClause orderByClause, QueryBinderContext context, Boolean alreadyOrdered)
at Microsoft.AspNetCore.OData.Query.OrderByQueryOption.AddOrderByQueryForProperty(IOrderByBinder orderByBinder, OrderByClause orderbyClause, IQueryable querySoFar, QueryBinderContext binderContext, Boolean alreadyOrdered)
at Microsoft.AspNetCore.OData.Query.OrderByQueryOption.ApplyToCore(IQueryable query, ODataQuerySettings querySettings)
at Microsoft.AspNetCore.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query, ODataQuerySettings querySettings)
at Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.ExecuteQuery(Object responseValue, IQueryable singleResultCollection, ControllerActionDescriptor actionDescriptor, HttpRequest request)
at Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.OnActionExecuted(ActionExecutedContext actionExecutedContext, Object responseValue, IQueryable singleResultCollection, ControllerActionDescriptor actionDescriptor, HttpRequest request)
at Microsoft.AspNetCore.OData.Query.EnableQueryAttribute.OnActionExecuted(ActionExecutedContext actionExecutedContext)
at Microsoft.AspNetCore.Mvc.Filters.ActionFilterAttribute.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
Controller Setup:
namespace ODataApiTest.Controllers.Odata
{
[Produces("application/json")]
[Authorize]
public class FutureCartController : ODataController
{
private readonly DatabaseContext _context;
private readonly ScopeData _scopeData;
public FutureCartController(DatabaseContext context, ScopeData scopeData)
{
_context = context;
_scopeData = scopeData;
}
[EnableQuery(PageSize = 250)]
public IQueryable<FutureCartItem> Get()
{
if (!_scopeData.User.HasPermission(DTO.PermissionNode.isAdmin))
throw new Exception("Permission Denied"); // TODO Proper exception
var baseQuery = _context.FutureCartItem;
return baseQuery;
}
}
}
Relevant Startup parts:
var modelBuilder = new ODataConventionModelBuilder();
var cartLine = modelBuilder.EntitySet<FutureCartItem>("FutureCart");
var scheduleProvisionings = modelBuilder.EntitySet<ScheduledProvisioning>("ScheduledProvisioning");
scheduleProvisionings.EntityType.Ignore(x => x.Error);
scheduleProvisionings.EntityType.Ignore(x => x.Trys);
public class FutureCartItem : Entity
{
public string Sku { get; set; }
public int Quantity { get; set; }
public bool AutoRenew { get; set; }
public Guid ScheduledProvisioningId { get; set; }
public ScheduledProvisioning ScheduledProvisioning { get; set; }
public Guid CatalogueId { get; set; }
}
public abstract class ScheduledTransaction : Entity
{
public Guid PartnerId { get; set; }
public Guid CustomerId { get; set; }
public string PlacedByUser { get; set; }
public DateTime PlacedAtUtc { get; set; }
public DateTime ScheduledFor { get; set; }
public DateTime? ProcessingStartedAtUtc { get; set; }
public DateTime? ProcessingEndedAtUtc { get; set; }
public ScheduledState State { get; set; } = ScheduledState.Unprocessed;
public ScheduledTransactionError Error { get; set; }
public ScheduledTransactionType Type { get; set; }
public int Trys { get; set; }
}
public class ScheduledProvisioning : ScheduledTransaction
{
public List<FutureCartItem> CartLines { get; set; }
}
public abstract class Entity
{
public Guid Id { get; set; }
}
The text was updated successfully, but these errors were encountered:
Hi @joamla96. Thank you for reporting the issue. Unfortunately I'm not able to reproduce it based on the provided details - in spite of my best effort. Can you share a simple repro that we can use to investigate the issue?
I've taken our application, and stripped away everything unrelated. Ill attach it here.
I was still able to reproduce the issue with this code, and the following URI: https://localhost:5041/odata/FutureCart?$apply=groupby((CatalogueId, ScheduledProvisioning/PartnerId, ScheduledProvisioning/State),aggregate(Quantity with sum as TotalQuantity))
Attempting to group-by and aggregate results in Expression Exception
Assemblies affected
Expected result
List of results
Actual result
Exception
Additional detail
Query:
GET https://localhost:5041/odata/FutureCart?$apply=groupby((CatalogueId, ScheduledProvisioning/PartnerId, ScheduledProvisioning/State),aggregate(Quantity with sum as TotalQuantity))
Logged Exception:
Controller Setup:
Relevant Startup parts:
Relevant Models:
The text was updated successfully, but these errors were encountered: