Как обновить модель в ASP.NET с помощью LINQ to SQL ?
В Ruby on Rails мы бы сделали это:
@record1 = Record.find(id) #Get the record
@record1.update_attributes(record2) #Data from record2 is copied to record1
Ион генерирует оператор обновления SQL.
[HttpPost]
public ActionResult Edit(int id, Record record)
{
//How would I do it in LINQ here?
}
Самое близкое, что я пришел, - это ручное копирование всех полей, то есть:
record1.name = record2.name
record1.something = record2.something