Search code examples
odata

How to build the EDM model for the OData service which having return type of KeyValuePair


Post Method:

[HttpPost]
public Dictionary<string, object> PostData(ODataActionParameters param)
{     
}

To Build EDM Model:

 ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
 var customSave = builder.EntityType<Model>().Collection.Action("PostData");

How to set the return of an action "customSave"?


Solution

  •  ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
     var customSave = builder.EntityType<Model>().Collection.Action("PostData");
     customSave.ReturnsCollection<Dictionary<string, object>>();
    

    To establish the return type of the Action used when the return type is a collection of either Primitive or ComplexTypes.