how to convert @sync_last_received_anchor bewteen bigint and byte[58] RRS feed

  • Question

  • I am using SqlCeClientSyncProvider with SQL CE 3.5 SP1 at client side; and DbServerSyncProvider with SQL Server 2008  + Change Tracking at server side.

    I noticed that SqlCeClientSyncProvider.GetTableReceivedAnchor(string tableName) return byte[58], however when it passed into sp, @sync_last_received_anchor becomes bigint (mathcing the data type of change_tracking_current_version()).

    Does anyone know how Sync Services for ADO.NET convert the values bwteen byte[58] and bigint?

    I am asking this because I want to call SetTableReceivedAnchor() based on change_tracking_current_version() in case rolling back of server db to previous backup.
    • Moved by Max Wang_1983 Thursday, April 21, 2011 11:52 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Thursday, August 27, 2009 11:40 PM


  • Found it va Reflector:

    Anchor (byte[58]) to bigint:

    using (MemoryStream serializationStream = new MemoryStream(anchor))
       object obj1 = new BinaryFormatter().Deserialize(serializationStream); // obj1 is bigint

    bigint to Anchor:

    object _rawNewAnchor = (long)73; //bigint
    using (MemoryStream serializationStream2 = new MemoryStream())
      new BinaryFormatter().Serialize(serializationStream2, _rawNewAnchor);
      SyncAnchor newAnchor = (new SyncAnchor());
      newAnchor.Anchor = serializationStream.ToArray();
    • Marked as answer by Bob H.L. _ Friday, August 28, 2009 7:03 AM
    Friday, August 28, 2009 7:03 AM