Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Created Issue: Make all id parameter in EntitySetController by using ODataModelBinder [599]

$
0
0
Replace ODataModelBinderProvider globally can cause more problems as it will try to bind all parameters which is not in odata format.
More proper fix is to add modelbinder using ModelBinderAttribute on all id parameters. However, we didn’t make binder type public. So a workaround is to create a custom model binder attribute:
public class ODataModelBinderAttribute : ModelBinderAttribute
{
public override System.Web.Http.Controllers.HttpParameterBinding GetBinding(System.Web.Http.Controllers.HttpParameterDescriptor parameter)
{
ODataModelBinderProvider provider = new ODataModelBinderProvider();
return new ModelBinderParameterBinding(
parameter,
provider.GetBinder(parameter.Configuration, parameter.ParameterType),
this.GetValueProviderFactories(parameter.Configuration));
}
}

Add this attribute to all ID parameter on all actions in EntitySetController.

Without it, user can't support string, guid, long as primary key in odata service.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>