Patch Delta is null
HTTP Patch on entity does not work.
I have 2 entities. They have the following structure -
public class Entity1
{
public string Id { get; set; }
public string Type { get; set; }
public ICollection<Entity2> Entity2List { get; set; }
}
public class Entity2
{
public string Id { get; set; }
public string Type { get; set; }
}
My Controller action is in the following format. It worked perfectly well before adding ICollection property in Entity1.
[EnableQuery]
[HttpPatch]
[ODataRoute("({id})")]
public IHttpActionResult PatchEntity1(string id, [FromBody][Required] Delta<Entity1> Entity1Delta)
{
// Entity1Delta here is null
}
My Configuration file is as follows -
internal static void Register(HttpConfiguration config)
{
config.SetUrlKeyDelimiter(ODataUrlKeyDelimiter.Slash);
config.Filter().Expand().Select().OrderBy().MaxTop(null).Count();
config.MapODataServiceRoute(
routeName: "ODataRoute",
routePrefix: "api",
model: GetModel());
}
/// <summary>
/// Get the EDM for the ODataControllers
/// </summary>
private static IEdmModel GetModel()
{
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Entity1>("entity1");
builder.EntitySet<Entity2>("entity2");
builder.EnableLowerCamelCase();
return builder.GetEdmModel();
}
Similar to: https://github.com/OData/WebApi/issues/945, #964
I am having the same issue. Not able to tell if this issue has been addressed or not?
@ricksearcy I was using it as a collection property and patch is not supported for that according to the spec. You can read the discussion here - https://github.com/OData/WebApi/issues/945 and https://github.com/OData/WebApi/blob/master/src/System.Web.OData/OData/Routing/Conventions/PropertyRoutingConvention.cs#L113
On using entity2 as a navigation property of entity1, Patch worked without any issues.