Reputation: 17
I'm preparing WinForm application with local DB. I want to remember changes, when somebody will leave application, he decide to save or discard changes. I expect to have three tables, and about 1000 rows in every table. On one window I have three tables which can be modified in every time. So for I have found some solution and I had use the Local method on context. eg.
people.DataSource = dbctx.People.Local.Where(...).ToList();
I recently I try to use dynamic linq query, and I couldn't use when I access to dbctx with Local. Is something better TransactionScope, IEditableObject? How to use it.
Upvotes: 0
Views: 89
Reputation: 12420
If they close the winforms application entirely (losing any in memory storage options) then you will need to use a store of some sort (database, file etc), as you are already using a database it sounds like your best option would be to store it in there.
If you are concerned about space etc, you could simply serialize the in memory objects (perhaps to json) and store it against the user record, then next time they log in/ come back you can deserialize it back to memory and they can carry on.
If you choose this option I would recommend using Json.Net:
To serialize your in memory records use:
string json = JsonConvert.SerializeObject(people);
And deserialize back out:
var people = JsonConvert.DeserializeObject<People>(json);
Upvotes: 1