Database Flush() method

Oct 17, 2012 at 12:34 PM

I store my database file on flash disk "\Flash\database.sdf" and to speed-up the reading I copy that file to RAM at "\database.sdf" and work with that copy. Each time when I Insert\Update table(s) I back up "\database.sdf" to "\Flash\database.sdf" but some time I see that some tables are absent on flash file. It looks like some tibles were cached and not saved into the file. I expected to find Flush() method but have not found it. How I can force flushing cache  to the file before I back up database to flash? Probably I should use another ConnectionBehavior value? Now I open databse like below:

 

var Store = new SqlCeDataStore("\\database.sdf")
{ ConnectionBehavior = ConnectionBehavior.Persistent, UseCommandCache = true };

 

Coordinator
Oct 18, 2012 at 10:38 PM

SQL Compact maintains its own flushing algorithm.  By default, it can wait up to 10 seconds to flush committed changes to disk.  This can be changed by modifying the 'flush interval' parameter of the connection string.  Currently ORM doesn't support doing this, you'd have to modify the source and rebuild to get that change.

Oct 19, 2012 at 1:11 PM

So I can set that value to 1 second, right? Is there any way to ensure that all changes were flushed to disk or I can only wait 'flush interval'?

Coordinator
Oct 19, 2012 at 3:21 PM

Sure, you can set it to any value you'd like, I believe.  There's no notification when it happens, so I'd wait for 1.5x or 2x the interval before copying.

Oct 19, 2012 at 6:54 PM

I set 1 sec for flush interval and 3 sec delay before copying (tried 2 sec but it was not success some time), it seems OK now. Thank you.