I have a simple WebAPI2 service that uses OData ( System.Web.Http.OData , 5.1.0.0). Users can press /odata/$metadata to get available objects and properties. I am looking for a way to extend this metadata to additional information, such as adding a display name value to a property.
I found โannotationโ information that sounds like I want to, but I canโt find anything explaining how to use this in my script or if possible. I tried to do something like the following:
model.SetAnnotationValue(((IEdmEntityType)m.FindType("My.Thing")).FindProperty("SomeProperty"), namespaceName:"MyNamespace", localName: "SomeLocalName", value: "THINGS");
The type / property names are correct and the call succeeds, but the OData EDMX document does not contain this annotation. Is there a way to post these annotations or otherwise do what I want?
Update :
Still on it. I considered ODataMediaTypeFormatters as a possible way to handle this. There is a sample ASP.NET project that shows how to add instance annotations to objects. Close, but not quite what I want, so now I'm trying to find a way to extend what the metadata document generates in a similar way.
source share