简体   繁体   English

L2E用于插入,更新,删除

[英]L2E for insert, update, delete

I am using .Net3.5. 我正在使用.Net3.5。 Just wondering my understanding about the insert, update, delete are correct when use L2E. 只是想知道我对使用L2E时插入,更新,删除的正确理解。

For insert, we need two statements: 对于插入,我们需要两个语句:

context.AddObject("entityName", newRow);
context.SaveChanges();

For update, we only need one statement: 对于更新,我们只需要一个语句:

context.SaveChanges();

For delete, we need two statements: 要删除,我们需要两个语句:

context.DeleteObject(deletedRow);
context.SaveChanges();

When performing an update you first need to update a property of an entity of course. 当然,执行更新时,您首先需要更新实体的属性。

Your code for insert and delete is correct. 您用于插入和删除的代码是正确的。

But what is your question actually? 但是,实际上您的问题是什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM