Description
As far as I know, currently in order to get e.g. $filter to work, I have to have
the entityset IModelConfiguration:
var stream = builder.EntitySet<MyClass>("MyClasses").EntityType;
stream.Filter()...
as well as [EnableQuery(AllowedQueryOptions = Filter...
added to the controller action.
Alternatively, in the controller I could do
public IActionResult Get(ODataQueryOptions<MyClass> options) {
var validationSettings = new ODataValidationSettings() {
AllowedQueryOptions = Filter,...
};
options.Validate(validationSettings);
return Ok(options.ApplyTo...
}
which also has double configuration to enable $filter.
There's also the global catchall option to enable $filter to every possible controller method, but that might not be preferable for everyone.
Would it be possible to validate the incoming ODataQueryOptions by the configuration in the EDM-model? This would reduce the amount of duplicate configuration required.
The way I would see this working is to have something like GetODataValidationSettingsFor(typeof(MyClass))
which would return an instance of ODataValidationSettings based on the model configuration. This would help to clarify the current configuration process (which configuration needs to enabled where and when), which is causing us some headaches.