Set a persistent DataSet that includes change tracking

I want to open a WCF service service that sends new records to the database. Each time an operation is called, it must return a DataSet that includes only rows that have been added to the database since the last operation call.

My question is whether this is possible by serializing the DataSet between calls, and then using the GetChanges () and AcceptChanges () methods.

Those. (pseudo code)

 [OperationContract]
 public DataSet GetDataSet() 
 {     
       DataSet ds = LoadDataSet();   // load a dataset from saved xml or binary

       DataSet newDs = GetRecordsFromDatabase(); // load dataset from database

       ds.Merge(newDs, true);  // somehow recognize which records in the newDs 
                               // load are new?
       return ds.GetChanges(); 
 }
+3
source share
1 answer

Try:

ds.GetChanges(DataRowState.Added)

My suggestion: Do not serialize datasets. Perhaps you can keep the ID of the last record you inserted.

Regards, M.

0
source

All Articles