I have a EF entity retrieved and bound to some UI controls using Unit of Work
public RowItem MyItem { get; set; }
using ( var ctx = new MyContext() )
MyItem = ctx.MyEntity.Single( x => /// parms };
at a later time, the updates are saved on some user action
Question – how can i use the existing entity MyItem and keep it simple along the lines of
using ( var ctx = new MyContext() )
MyItem.UpdateUsingContext(ctx);
Well, saving an object in EF is simple:
This saves all updated/new/deleted object in
context.If your objects were not created in this particular instance of
contextyou should attach them before saving: