locked
Confusion about DbSyncContext and Batch Files RRS feed

  • Question

  • This is a question for version 2.0. Is what is stored in the batch spool files merely the serialized DataSet or DbSyncContext for each batch?

    I was under the impression that during the first call to GetChanges all data would be spooled to multiple files, and then the first would be deserialized for that call. Then, subsequent calls would result in deserializing the rest of the spool files. I thought that the spool files were only used as a place to cache the data until it could be processed.

    However, in the WebSharingAppDemo it is both sending back the full DbSyncContext and downloading the batch file. According to How to: Deliver Changes in Batches, the DataSet should have been null if IsDataBatched was true; but it wasn't while running the demo.

    I would actually prefer to just send back the DbSyncContext if possible, and let the database provider deal with managing the batch files. So I would like DataSet to not be null. But I wanted to check to make sure this wasn't a bug (meaning the DataSet should have been null) and that there wasn't other information in the batch files that was not part of the DbSyncContext.

    • Moved by Max Wang_1983 Thursday, April 21, 2011 10:49 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Monday, October 26, 2009 3:19 AM

Answers

  • Hi,

    When you tried to access the DbSyncContext.DataSet property, if it is null, the local batching file will be deserialized to the DataSet instance. If the batching file is not sent to another side in the websharing demo, the DataSet will remain null when IsDataBatched = true.

    Also, it will not work if you just send the DbSyncContext with not-null DataSet because the the internal implementation doesn't support this way due to knowledge handling and security concerns. You need to follow the WebSharing sample to send batching files across the wire.

    Thanks,
    Dong
    This posting is provided AS IS with no warranties, and confers no rights.
    Tuesday, October 27, 2009 4:55 PM
    Moderator
  • Hi Joe,

    When IsDataBatched is true, as long as you don't try to get the DbSyncContext.DataSet property before the client proxy ApplyChanges call, the internal dataset value will remain null, and same data will not be transfered twice.  

    If you have to load the DataSet in the client proxy side for whatever reason, you can set DataSyncContext.DataSet = null right before the client proxy call.

    Thanks,
    Dong
    This posting is provided AS IS with no warranties, and confers no rights.
    Wednesday, October 28, 2009 6:28 PM
    Moderator

All replies

  • Hi,

    When you tried to access the DbSyncContext.DataSet property, if it is null, the local batching file will be deserialized to the DataSet instance. If the batching file is not sent to another side in the websharing demo, the DataSet will remain null when IsDataBatched = true.

    Also, it will not work if you just send the DbSyncContext with not-null DataSet because the the internal implementation doesn't support this way due to knowledge handling and security concerns. You need to follow the WebSharing sample to send batching files across the wire.

    Thanks,
    Dong
    This posting is provided AS IS with no warranties, and confers no rights.
    Tuesday, October 27, 2009 4:55 PM
    Moderator
  • Thanks for the info Dong.

    Is there any way to prevent the DataSet from being serialized? Right now it appears that because the DataSet property is deserialized upon access, when the DbSyncContext is serialized, the entire DataSet is as well. So if I also need to download the batch file, then I will end up having to transfer the same data twice.
    Wednesday, October 28, 2009 3:40 AM
  • Hi Joe,

    When IsDataBatched is true, as long as you don't try to get the DbSyncContext.DataSet property before the client proxy ApplyChanges call, the internal dataset value will remain null, and same data will not be transfered twice.  

    If you have to load the DataSet in the client proxy side for whatever reason, you can set DataSyncContext.DataSet = null right before the client proxy call.

    Thanks,
    Dong
    This posting is provided AS IS with no warranties, and confers no rights.
    Wednesday, October 28, 2009 6:28 PM
    Moderator
  • Thanks Dong. I double-checked my code, and found a spot I missed where I was accessing the DataSet. Once I commented out that line, I saw that the DataSet data was no longer being transferred with the DbSyncContext.
    Thursday, October 29, 2009 5:41 AM