OData string property lacks MaxLength support

Topics: ASP.NET Web API
Jul 2, 2014 at 3:14 PM

I've noticed that event if OData v4 Edm libraries provided the MaxLength property for string edm properties, the OData model builder does not define a way to set this property. However, this is very convenient to auto generate client validation through the edm model.

Behind this, we can underline that some parts of edm definition are set from reflection on .NET attributes (for instance KeyAttribute, RequiredAttribute), using the conventions of the OData convention model builder. The thing is the set of classes and interfaces handling the conventions is totally internal, so it prevent developpers to extend defaut behavior of the convention builder.

So it could be good to make those interfaces public and allow developers to register custom conventions, to allow for instance to reflect MaxLengthAttribute on objects to configure the edm string properties.

Hope it can help.