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

Closed 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.<br />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:<br /> public class ODataModelBinderAttribute : ModelBinderAttribute<br /> {<br /> public override System.Web.Http.Controllers.HttpParameterBinding GetBinding(System.Web.Http.Controllers.HttpParameterDescriptor parameter)<br /> {<br /> ODataModelBinderProvider provider = new ODataModelBinderProvider();<br /> return new ModelBinderParameterBinding(<br /> parameter, <br /> provider.GetBinder(parameter.Configuration, parameter.ParameterType),<br /> this.GetValueProviderFactories(parameter.Configuration));<br /> }<br /> }<br /><br />Add this attribute to all ID parameter on all actions in EntitySetController.<br /><br />Without it, user can't support string, guid, long as primary key in odata service.
Comments: Verified

Viewing all articles
Browse latest Browse all 7215

Trending Articles



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