Search code examples
visual-studio-lightswitchlightswitch-2012

Synchronizing two Lightswitch applications


As my title says, I need to figure out how to sinchronize two of my Microsoft Lightswitch applications between eachother. Also, what is important is that one app is on web and other one is created for desktop.

So, what I need is to pull down database entries from web server and place it into database which is used by desktop PC.

Let me know if you need some more informations.


Solution

  • As Yann said, it's not a built in feature out-of-the-box, but it should be possible to do it in Lightswitch in code.

    You would need to manually write the code to do the actual syncing (by connecting to your database on the web server and syncing the data using SQL queries) but as this can't be done in the client (Silverlight doesn't allow SQL classes to be used) you can use the 'Command Table' pattern (http://blog.pragmaswitch.com/?p=332).

    Basically, you create a new table (for example, SyncRequests) and add a record to it from the client, then you can use server code (via the SyncRequests_Inserted event) to execute your sync code.

    The actual code for syncing the databases will depend on what exactly you want to do (overwrite all data in local DB from web DB, merge records, only add new, etc.) and on your DB structure in general.