Dataset Serialization using Dataset Surrogate RRS feed

  • Question

  • Hi,

         I am facing the problem of getting different datetime values that the original in Sync Framework2.0. After searching forums I found that it is the known issue of Dataset Serialization in .Net Framework.

    I gone through the articles http://support.microsoft.com/kb/842545/en-us?p=1  & http://support.microsoft.com/kb/829740/ as workaround for this problem. I am thinking of using DatasetSurrogate as I am using .Net Remoting as an transport for the Sync Framework. In order to use the DatasetSurrogate I am not able to figure out where I need to intercept the DataSet in sync process. I think I should intercept it in the GetChanges method. But not able to get the dataset retrived containing the changes.

    Can you please guide me or give some reference on how to intercept the dataset that is being retrived in GetChanges?



    Wednesday, September 15, 2010 10:41 AM

All replies

  • have you tried intercepting in ChangesSelected instead? the event args will have the SyncContext that contains the Dataset.

    chk this out for other ideas: http://jtabadero.spaces.live.com/blog/cns!BF49A449953D0591!1208.entry

    Wednesday, September 15, 2010 3:01 PM
  • Thanks JuneT,

                    I intercepted the dataset in ChangesSelected and set the ExtendedProperties of dataset with the UTCDifference and retrived the this value at other end in ApplyingChanges. This works.

    But when I syncronize data in Batches, I am not getting the ExtendedProperties ApplyingChanges.

    Why the ExtendedProperties are being lost when syncronizing the data in batches?




    • Edited by AjinathWaghmode Thursday, September 16, 2010 9:37 AM spell mistake
    Thursday, September 16, 2010 8:29 AM
  • not sure why, but are you doing anything different for your batching?
    Thursday, September 16, 2010 2:42 PM
  • I am doing nothing different. Just have set the MemoryDataCacheSize = 1 instead of 0 to enable the batching. This is also happening in the demo example 'WebSharingAppDemo-SqlProviderEndToEnd'


    Does anyone implemented batching?



    Friday, September 17, 2010 5:20 AM
  • just a thought, when you enable batching, the changes are sent by SyncFx using a dataset surrogate and sync fx converts it back to a dataset on the remote side. so the Extended Property you set on the client side dataset is lost. if i remember it right, only the Locale (cultureinfo), schema and the data is restored back to the dataset.
    Friday, September 17, 2010 6:21 AM
  • Thanks JuneT for the reply. Does the statement 'when you enable batching, the changes are sent by SyncFx using a dataset surrogate and sync fx converts it back to a dataset on the remote side'  means that the DataSet is converted to it's DatasetSurrogate and sent ot the remote, one the remote DataSet is restored from it's DatasetSurrogate? So does this uses the Dataset Serialization? If it does uses the dataset serialization, the DateTime problem should not occur in case of different time zones.

    What do you say?




    Friday, September 17, 2010 6:37 AM
  • Hi JuneT,

                Is there anyway to force Sync Fx to send the DatasetSurrogate in non batch mode? Because if DatasetSurrogate sent instead of Dataset the DateTime problem doesn't occur.

    I see that when the (HUGE) data is being synced in multiple batches the DateTime problem doesn't occur (because I guess here DataSet serialization doesn't occur). But when the data is small in size (less than the MemoryDataCacheSize), the batch mode is disabled and the data is being sent in DataSet which causes the DateTime problem (DataSet serialization occurs). Here I can check that if there is an Extended property for UTCTimeDifference then I will intercept the DataSet and change the DateTime values accordingly. But I dont want to add this overhead of enumerating each table , each row for DateTime change. 

    If I force the Sync Fx to send the DataSetSurrogate instead of DataSet even in disabled batch mode,  do not need to intercept the DataSet and manipulate the DateTime values.

    Your thoughts are really valuable for me.


    Friday, September 17, 2010 8:15 AM
  • no, the DatasetSurrogate is not even exposed publicly. So there is no way to override it.

    Why dont you just put a check in your code so that if batching is enabled, you dont use the Dataset Extended Properties and vice versa?

    so on ChangesSelected, you check if batched. If batch, just leave it as it is. If not batched, put in the Extended Property.

    Friday, September 17, 2010 8:21 AM
  • Yes. I am already started to implement in the way you suggested. But was just trying to figure out if there is anyway to overcome the overhead of intercepting the DataSet and manipulating the DateTime values. I am not comfortable with this approach b'coz enumerating every row for the table that contains the DateTime column will certainly affect the performance.

    Anyways, right now it seems that there is no way except the above you suggested.

    Thanks for your response.



    Friday, September 17, 2010 9:26 AM
  • using utc dates in the database is the less painful option :)
    Friday, September 17, 2010 2:34 PM