I think you can use something like DataContext.Table.Attach (record, true) and then DataContext.SubmitChanges (). But I do not have it completely hidden ...
So now I have done the test. This will only work if you do not require a concurrency check (i.e. you are only updating the table).
Here is my table
People PersonID int FirstName varchar(50) LastName varchar(50)
I filled the table with the following entry
> PersonID FirstName LastName > 1 Jason Punyon
I created a LINQ2SQL DataContext with only this PeopleDataContext table and for each property of the People class I set the UpdateCheck property for each property of the Never record.
Here is the code:
static void Main(string[] args) { var p = new People(); p.PersonID = 1; p.FirstName = "Jason"; p.LastName = "This is a new last name"; using (var db = new PeopleDataContext()) { db.Peoples.Attach(p, true); db.SubmitChanges(); } }
And it works successfully. No reflection or anything else, but as I said, you lose the concurrency check.
Jason punyon
source share