Skip to content

Aggregate Statement on Collection of IEdmEntityObjects cant find property #918

Closed

Description

@vrkrishn

I was wondering whether aggregation was supported for methods that return EdmEntityObjectCollection (i.e. with type parameter Contact). I see that in all the examples, the controller methods return IQueryable but I'm not sure if that would work if the method expects IEdmEntityObjects rather than aspecific contact object. Currently I am running into an exception where I cannot find a property defined in the Contact entityType.

Assemblies affected

Microsoft.AspNet.OData 5.9.1
Microsoft.OData.Core 6.15
Microsoft.OData.Edm 6.15

Reproduce steps

GET /data/Contacts?$apply=aggregate(Date with min as Earliest)

Expected result

{
@odata.context":"http://hostname/data/$metadata#Contacts,
"value": [
{
"@odata.id": null,
"Earliest": Datetime Object
}
]
}

Actual result

"error":{
"code":"","message":"The query specified in the URI is not valid. Could not find a property named 'Date' on type 'System.Web.OData.IEdmEntityObject'.
}

Activity

  1. TehWardy commented on Apr 4, 2017

    @TehWardy

    I have a similar problem when I use groupby with a DateTime property in the same version assemblies ...

    ~/Api/MyType?$apply=groupby((DueDate))

    With the DueDate property on the type being a DateTime it returns ...

    {
      "error": {
        "code": "",
        "message": "An error has occurred."
      }
    }
    

    doing a normal "get all" query with the url "~/Api/MyType" returns the data fine and displays the datetime properties correctly as ISO strings as I would expect.

  2. TehWardy commented on Apr 4, 2017

    @TehWardy

    Ah looks like my problem is #912
    Could be related though I guess ???

  3. linked a pull request that will close this issuegroup by on date throws exceptions #2302on Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions