如何使用ADo.net数据实体模型更新行ionto数据库?

时间:2021-06-17 06:53:25

How I can Update the row into database using ADo.net Data Entity Model?

如何使用ADo.net数据实体模型将行更新到数据库?

1 个解决方案

#1


each data row is represented by an object.

每个数据行由一个对象表示。

you just need to fetch the required row, update the relevant property and save the changes using the object context.

您只需要获取所需的行,更新相关属性并使用对象上下文保存更改。

for example:

using(MyContext db = new MyContext())
{

var customer = db.Customers.First();


customer.Name = "New Value";

db.SaveChanges();

}

And your'e done. Hope this helps.

你做完了。希望这可以帮助。

#1


each data row is represented by an object.

每个数据行由一个对象表示。

you just need to fetch the required row, update the relevant property and save the changes using the object context.

您只需要获取所需的行,更新相关属性并使用对象上下文保存更改。

for example:

using(MyContext db = new MyContext())
{

var customer = db.Customers.First();


customer.Name = "New Value";

db.SaveChanges();

}

And your'e done. Hope this helps.

你做完了。希望这可以帮助。