views:

36

answers:

1

So I load up an object like...

MyObject object = new MyObject();

object = objectRepository.getObjectByID(id);

object.lastLoaded = DateTime.Now();

...
//NOW WHAT????

I know there is a .Save() but does that update the current one or is that only used for creating new ones?

+3  A: 

You want to use the SubmitChanges() method available on your DataContext.

Quick example:

public void updateLoadDate(int id)
{
    using(LinqDataContext db = new LinqDataContext())
    {
        var myObject = (from object in db.objects
                       where object.id == id
                       select object).SingleOrDefault(); 

        myObject.lastloaded = DateTime.Now();

        db.SubmitChanges();
    }
}
Simucal