none
Getting only updated and new rows (timestamp) RRS feed

  • Question

  • Hello,

    I have a database problem. I have like a local database where I keep data that I use. But, the data of my DB comes from a master database which contains lots and lots of data (most that I don't need). The master DB (MDB) is on the network, the local DB (LDB) is local on the computer.

    Now, all the records on the MDB have a timestamp column. Now, I want to sync my LDB with the MDB by only getting new and updated rows where column1 = val1 and column3 = val2.

    Can I, and how do I, achieve this with the Entity framework?

    The LDB is the free version of Microsoft SQL Server 2008R2, the MDB is the full version of Microsoft SQL Server 2005.

    How do I start? Ok, I "imported" both Databases in my visual studio C# project, now how can I get only the new and updated rows that meet certain conditions? And this with minimal network traffic offcourse. It's no use to get all the records of the Master Database (which is really big) and then just code it. I really want that only the rows I need are transfered from the master to the local.

    Any help is welcome, please keep in mind that I'm not expercienced in entities and even less in SQL.

    Thanks!

    Wednesday, January 25, 2012 9:14 AM

Answers

  • Hi Denny007,

    I think you can try to map two EDMXs to each database, please use different namespace to distinguish their entities. The Timestamp will be mapped with Byte[] in entity, you can retrieve them then compare them to see if there are same, you can try to use "SequenceEqual" to compare the two Byte[] array. If there are different, you can use SQL2005's records update the LDB records.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 30, 2012 2:03 AM
    Moderator

All replies

  • after searching a while, and not getting info anywhere, I think it's quite impossible, or at least verry hard. So I gave up this thinking path.

     

    Thanks for anyone who thought with me.

    Friday, January 27, 2012 3:48 PM
  • Hi Denny007,

    I think you can try to map two EDMXs to each database, please use different namespace to distinguish their entities. The Timestamp will be mapped with Byte[] in entity, you can retrieve them then compare them to see if there are same, you can try to use "SequenceEqual" to compare the two Byte[] array. If there are different, you can use SQL2005's records update the LDB records.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 30, 2012 2:03 AM
    Moderator