AutoMapper/AutoMapper.Extensions.OData

$select should work for simple properties as well

MeikelLP opened this issue · 9 comments

According to the spec $select should work for simple properties, but it does not.

Entities

[{
  "Name": "Test1",
  "Id": "07e61d50-30af-42a6-8aa4-4911509cd742"
},
{
   "Name": "Test2",
   "Id": "3e9b144a-0cd7-4068-b9b3-84ad7d600944"
}]

Query

?$select=Name

Expected Result

[{
   "Name": "Test1"
},
{
   "Name": "Test2"
}]

Actual Result

[{
  "Name": "Test1",
  "Id": "07e61d50-30af-42a6-8aa4-4911509cd742"
},
{
   "Name": "Test2",
   "Id": "3e9b144a-0cd7-4068-b9b3-84ad7d600944"
}]

Pretty sure you can do that with this library. The following is from one of the sample applications:

image

Here I got a working repository:
https://github.com/MeikelLP/automapper-odata-bug

This happened in 2 projects (private and in-company) and this triggers me now that hard that I created a sample for you :D

image

Your configuration has not been setup with explicit expansion - that's probably the difference.

So by design I must make all props expandable or else select will not work? Isn't that kind of unintuitive?

I added ExplicitExpansion but it still does not work (repo updated)

So by design I must make all props expandable or else select will not work? Isn't that kind of unintuitive?

PRs are welcome for a different approach.

Issues are really for bugs you've discovered in the library. I would start with the working sample applications or the tests and figure it out from there.

Issues are really for bugs you've discovered in the library. I would start with the working sample applications or the tests and figure it out from there.

Ok, Bug: ExplicitExpansion doesnt do anything

I think the tests say otherwise.