locked
save only changes of certain entity or object RRS feed

  • Question

  • Hi

    is it possible to save the changes only of a certain entity, resp. only of a certain object, programatically?

    regards

    Oliver


    • Edited by OlimilO Monday, September 16, 2013 2:22 PM
    Monday, September 16, 2013 12:02 PM

Answers

  • Hi Oliver,

    Yes it is possible to save changes to a certain entity programmatically.  The key to do this is to create an new DataWorkspace that contains the changes you want to save independently from anything else.  Here is an example of how to create a new DataWorkspace and use it to create an entity, query an entity, update an entity, and save those changes.

    DataWorkspace workspace = this.Application.CreateDataWorkspace();
    
    Table1Item newEntity = workspace.ApplicationData.Table1Items.AddNew();
    newEntity.Name = "New Entity";
    
    Table1Item updatedEntity = workspace.ApplicationData.Table1Items_Single(5);
    newEntity.Name = "Modified Entity";
    
    workspace.ApplicationData.SaveChanges();
    
    HTH
    Monday, September 16, 2013 2:35 PM

All replies

  • Hi Oliver,

    Yes it is possible to save changes to a certain entity programmatically.  The key to do this is to create an new DataWorkspace that contains the changes you want to save independently from anything else.  Here is an example of how to create a new DataWorkspace and use it to create an entity, query an entity, update an entity, and save those changes.

    DataWorkspace workspace = this.Application.CreateDataWorkspace();
    
    Table1Item newEntity = workspace.ApplicationData.Table1Items.AddNew();
    newEntity.Name = "New Entity";
    
    Table1Item updatedEntity = workspace.ApplicationData.Table1Items_Single(5);
    newEntity.Name = "Modified Entity";
    
    workspace.ApplicationData.SaveChanges();
    
    HTH
    Monday, September 16, 2013 2:35 PM
  • Great, Thanks!

    Kind regards

    Oliver

    Monday, September 16, 2013 3:24 PM