The templated Delete action for an "API controller with read/write actions, using Entity Framework" produces the following code:
Platform platform = db.Platforms.Single(p => p.Id == id);
if (platform == null)
{
return Request.CreateResponse(HttpStatusCode.NotFound);
}
If I'm not mistaken, Single will throw on a null/no elements in sequence, and so the null check in the 2nd line will never run and the 404 will not be returned.
The template needs to be updated to use SingleOrDefault.
Thanks!
Platform platform = db.Platforms.Single(p => p.Id == id);
if (platform == null)
{
return Request.CreateResponse(HttpStatusCode.NotFound);
}
If I'm not mistaken, Single will throw on a null/no elements in sequence, and so the null check in the 2nd line will never run and the 404 will not be returned.
The template needs to be updated to use SingleOrDefault.
Thanks!