I have an entity that has so many properties that I don't want to have to manually do something like
public void Update(Contact cont)
{
using (var ctx = new DatabaseEntities())
{
var res = from n in ctx.Contacts
where n.ContactID == cont.ContactID
select n;
var selContact = res.First();
selContact.AddressSuiteNumber = cont.AddressSuiteNumber;
selContact.PhoneNumber = cont.PhoneNumber;
/* and doing this for eeeeeeevery 40 properties */
ctx.SaveChanges();
}
}
I tried
selContact = cont
To no avail. Is there any such quick way to copy data from the instance of the entity passed as argument in the Update() method to the one found in the LINQ select and then save it?