AspNetCoreOData
AspNetCoreOData copied to clipboard
Fixes #766, Support in memory filtering after ODataQueryOptions.ApplyTo
Fixes #766.
If we have $select and $expand in the request query, the result is collection of ISelectExpandWrapper.
It's not easy for customers to do further. So Add 'Cast' Extension methods on IQueryable and Object.
Basic usage in the controller/action:
IQueryable query = options.ApplyTo(....);
IEnumerable<Customer> results = query.OCast<Customer>(query); // the new extension methods on IQueryable.
foreach (var a in results)
{
// a is a partial object of Customer if we have $select and $expand.
}
Thanks.
@julealgon Please take a look and share your thoughts.
We need this. Any updates??
We had a discussion on this today -- what is the expected behavior if there is a $select applied to the query on which OCast<T>() is called? should we ignore the $select and set all of the properties, or should we only set the properties that are specified in $select and leave it to the developer to somehow understand which properties have been set and which have not?
Awesome! I would expect the select to work. I can't use the select clause with IQueryable so I have to add the needed properties in my endpoint using the Select method.
From my understanding, this PR would fix the issue.
or should we only set the properties that are specified in $select
Wouldn't that clash with required properties? What if the user didn't select some properties that are marked as required in the original model? If you then try to recreate the same object but only set the selected properties, this will fail.