Our application uses LINQ and SQL compact database .sdf file as datasource. It is using Miscrosoft SQL Server Compact 3.5 SP 1 and .NET Framework 3.5 SP1.
We store our application's project data into a .sdf file. When our application opens a .sdf file (e.g. projectA.sdf), it will make a temporary copy of it and open the temporary file instead of the original file. If we change one table cell value
(i.e. one property value of an object that is created by LINQ), and call DataContext.SubmitChanges(ConflictMode.ContinueOnConflict), and then call
File.Copy(DataContext.Connection.Database, filename, true);
to copy the temporary file back to the original file (replacing the original one).
We found that the table value is not changed in projectA.sdf. But in the temporary copy, the value is changed. If we re-open db connection by calling
right before calling File.Copy(), the changed value is copied successfully to projectA.sdf.
If we do a lot of value changes in the database, or adding / deleting table row, then submit changes. Without re-opening the db connection, after File.Copy(), the projectA.sdf have those changes copied.
This strange behaviour looks like the temporary db file is cached. For a small change, the cached version is not changed. The File.Copy() use t
View Complete Post