Delete a LINQ to SQL record without loading it first
.net, linq-to-sql, performance
Solution
You should be able to do it this way:
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
}
Problem
Is it possible to get LINQ to SQL to delete a record using the PK, without loading the record first? Similar to NHibernate's proxy object functionality?