'ODataQueryOptions do not response the property which is my custom class

I have an entity like this

public class MyDto
{
    public string string1;
    public string string2;
    public MyCustomClass myCustomClass;
}

I have two controller, One of them is fully compliant with OData's specifications, contains all CRUD, all of them run well.

And another one use different route to do similar CRUD like this:

[Route('newWay')] //did not use ODateRoutePrefix here
public class SecondController: ODataController
{
    [HttpPost]
    [Route('create')]
    public async Task<IActionResult> Create(...);

    [HttpPatch]
    [Route('update')]
    public async Task<IActionResult> Update(...);

/* Here's the problem */
    [HttpGet]
    [Route('get')]
    [EnableQuery]
    public async Task<IQueryable<MyDto>> Get(ODataQueryOptions<MyDto> option);
/* Here's the problem */
}

When a post like this newWay/get?$select=myCustomClass, it shows an empty Dto like this

[]

When a post like this newWay/get?$select=myCustomClass,string1, it shows only string1 like this

[
    "string1": "balabala"
]

But when I post without select property, it can return all correctly

So what happens to my second controller?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source