c# - SQL Server CE records gone when app is forced close or restarted device while app is open -
i have odd problem records using sql server ce in wpf application. far have been successful in storing records on database. have set of settings access when opening application. i'm using linqpad in order view database records.
here's how save database records.
using (var dbc = new mydbcontext()) { var settings = new usersetting(); settings.userid = appuser.user.id; settings.minimizekey = minimizekey; settings.startstopkey = startstopkey; settings.isstartatstartup = isstartatstartup ?? false; settings.isstorestate = isstorestate ?? false; dbc.usersettings.add(settings); dbc.savechanges(); }
after saving, view settings table , can see records there. problem is, when restart device while application open. record seems gone. on other hand, when close application before restarting, records still there. restarting device while app still open not practice, happen once in while , want records still there.
any ideas? thanks!
by default, sql ce has flush interval of 10 seconds. can set 1 second adding:
;flush interval=1
to connection string
or can force immediate flush, described here: http://erikej.blogspot.dk/2013/05/sql-server-compact-code-snippet-of-week_21.html
Comments
Post a Comment