【发布时间】:2014-01-03 01:02:15
【问题描述】:
如何更新数据库中的一行,包括 where 子句?
我的 c# 代码-
[HttpPost]
public ActionResult Index(string ID, string notes)
{
SampleDBContext db = new SampleDBContext();
// update table name Customers, set row `customerNote` with passed string notes, where `id` == given string ID
return View();
}
谁能帮帮我
【问题讨论】:
-
我建议您阅读有关您正在使用的数据访问技术的介绍性教程。 (Linq to SQL?实体框架?)这是基本功能。本质上,您在 DB 上下文中找到对象实例,更新其属性,并将更改保存在 DB 上下文中。
-
从msdn看这个系列教程:blogs.msdn.com/b/webdev/archive/2013/11/01/…
标签: asp.net-mvc database entity-framework asp.net-mvc-4