AutoMapper / AutoMapper.Extensions.OData

Creates LINQ expressions from ODataQueryOptions and executes the query.
MIT License
140 stars 38 forks source link

$select should work for simple properties as well #110

Closed MeikelLP closed 2 years ago

MeikelLP commented 2 years ago

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"
}]
BlaiseD commented 2 years ago

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

image

MeikelLP commented 2 years ago

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

BlaiseD commented 2 years ago

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

MeikelLP commented 2 years ago

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

MeikelLP commented 2 years ago

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

BlaiseD commented 2 years ago

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.

BlaiseD commented 2 years ago

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.

Harry-Loud commented 2 years ago

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

BlaiseD commented 2 years ago

I think the tests say otherwise.