Skip to content

$expand with count #137

@cheng93

Description

@cheng93

The [email protected] properties are missing.

In the following sample, there are two examples

  • Using EnableQuery and ProjectTo, this works
  • Using this library, this doesn't work

Sample https://github.com/cheng93/AutoMapper.OData/blob/master/ApiController.cs

http://localhost:5238/odata/categories?$expand=products($count=true)

expected

{
 "@odata.context": "http://localhost:5238/odata/$metadata#categories(Products())",
    "value": [
        {
            "CategoryId": 1,
            "CategoryName": "CategoryOne",
            "[email protected]": 3, <-- visible
            "Products": [
                {
                    "ProductId": 1,
                    "ProductName": "ProductOne"
                },
                {
                    "ProductId": 2,
                    "ProductName": "ProductTwo"
                },
                {
                    "ProductId": 3,
                    "ProductName": "ProductThree"
                }
            ]
        },
        {
            "CategoryId": 2,
            "CategoryName": "CategoryTwo",
            "[email protected]": 2, <-- visible
            "Products": [
                {
                    "ProductId": 4,
                    "ProductName": "ProductFour"
                },
                {
                    "ProductId": 5,
                    "ProductName": "ProductFive"
                }
            ]
        }
    ]
}

actual

{
    "@odata.context": "http://localhost:5238/odata/$metadata#categories(Products())",
    "value": [
        {
            "CategoryId": 1,
            "CategoryName": "CategoryOne",
            "Products": [
                {
                    "ProductId": 1,
                    "ProductName": "ProductOne"
                },
                {
                    "ProductId": 2,
                    "ProductName": "ProductTwo"
                },
                {
                    "ProductId": 3,
                    "ProductName": "ProductThree"
                }
            ]
        },
        {
            "CategoryId": 2,
            "CategoryName": "CategoryTwo",
            "Products": [
                {
                    "ProductId": 4,
                    "ProductName": "ProductFour"
                },
                {
                    "ProductId": 5,
                    "ProductName": "ProductFive"
                }
            ]
        }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions