Nei*_*ell 6 .net performance linq-to-sql
是否有可能让LINQ to SQL使用PK删除记录,而不首先加载记录?类似于NHibernate的代理对象功能?
Jos*_*eph 16
你应该能够这样做:
var person = new Person();
person.ID = someID;
using (var context = new DataContext(connString))
{
context.Persons.Attach(person, false); //attach is as unmodified
context.Persons.DeleteOnSubmit(person); //remove it
context.SubmitChanges(); //submit changes to db
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2267 次 |
| 最近记录: |