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.
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.