Updating an object with L2S with ASP.NET MVC

Posted by Paul on Stack Overflow See other posts from Stack Overflow or by Paul
Published on 2010-04-29T23:32:11Z Indexed on 2010/04/29 23:37 UTC
Read the original article Hit count: 215

Filed under:
|

Is there an easier way to update an object with L2S other then doing it property by property?

This is what I am doing now:

Public ActionResult Edit(Object obj)
{
    var objToUpdate = _repository.Single<Object>(o => o.id = obj.id);
    objToUpdate.Prop1 = obj.Prob1;
    objToUpdate.Prop2 = obj.Prop2;

    ...

    _repository.SubmitChanges();
}

I am hoping there is a way to just say objToUpdate = obj then submit the changes???

Any help on this would be appreciated!

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about asp.net-mvc