Skip to content

Commit e3b3802

Browse files
committed
Fix the Update action method to actually save changes into the DB
1 parent d7a2cec commit e3b3802

File tree

3 files changed

+2
-2
lines changed

3 files changed

+2
-2
lines changed
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

grid/odata-v4-web-api-binding/OdataTest/Controllers/ProductsController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ public IQueryable<Product> GetProducts()
3636
}
3737

3838
// PUT: odata/Products(5)
39-
public IHttpActionResult Put([FromODataUri] int key, Product test)
39+
public IHttpActionResult Put([FromODataUri] int key, Product product)
4040
{
4141
if (!ModelState.IsValid)
4242
{
4343
return BadRequest(ModelState);
4444
}
4545

46-
Product product = db.Products.Find(key);
4746
if (!ModelState.IsValid)
4847
{
4948
return BadRequest(ModelState);
@@ -54,6 +53,7 @@ public IHttpActionResult Put([FromODataUri] int key, Product test)
5453
return BadRequest();
5554
}
5655

56+
db.Products.Attach(product);
5757
db.Entry(product).State = EntityState.Modified;
5858

5959
try

0 commit comments

Comments
 (0)