Sync two SqlExpress using NHibernate

Posted by Christian on Stack Overflow See other posts from Stack Overflow or by Christian
Published on 2010-01-28T09:41:04Z Indexed on 2010/05/27 9:01 UTC
Read the original article Hit count: 240

Filed under:
|

Hello,

I am creating a simple project management system which uses NHibernate for object storage. The underlying database is SQL express (at least currently for development).

The client runs on either the desktop or laptop. I know I could use web-services and store the DB only on the desktop, but this would force the desktop to be available all the time.

I am currently thinking about duplicating the DB, having two instances with "different data". To clarify, we are not talking about a productive app here, its a prototype.

One way to achieve this very simple would be the following process:

  • Client: Check if desktop DB is available (through web service)
  • Client: If yes, use desktop storage, no problem here
  • Client: If not, use own DB as storage
  • Client: Poll desktop regulary, as soon as it comes on, sync
  • Client: Switch to desktop storage
  • ...
  • Desktop: Do not attempt any DB operation before checking for required sync
  • Desktop: If sync needed, do it...

My question is now, how would you sync? Assume 4 or 5 types of objects, all have GUID as identifiers. Would you always manually "lazy load" all objects of a certain type and feed them to the DB. Would you always drop the whole desktop DB in case the client DB may be newer and out of sync?

Again, I want to stress out, I am not assuming any conflicts or stale data, I basically just want to "copy the whole DB from the client". Would you use NHibernate for this? Or would you separate the copy process?

When I think about it, my questions comes down to this:

Is there any function from NHibernate:

SyncDBs_SourceWins_(SourceDB, TargetDB)

Thanks for help, Chris

© Stack Overflow or respective owner

Related posts about c#

Related posts about nhibernate