作者:gerardlong | 来源:互联网 | 2023-05-17 23:50
ImwritinganewWindowsForms2.0application.Thisapplicationisgoingtohaveadatafile.The
I'm writing a new Windows Forms 2.0 application. This application is going to have a data file. The user will be able to open the data file, do some work and save it to disk. Then he'll be able to open it later, to continue working. Same thing as Microsoft Word and .doc files.
我正在编写一个新的Windows Forms 2.0应用程序。该应用程序将具有数据文件。用户可以打开数据文件,做一些工作并将其保存到磁盘。然后他就可以打开它,继续工作。与Microsoft Word和.doc文件相同。
I'd like to use SQLite for the data file. However, I don't want changes to be written immediately to the data file. I want the user to change the data, but the file on disk remaining unchanged. Only when the user clicks "save" the data file on disk will be changed.
我想使用SQLite作为数据文件。但是,我不希望将更改立即写入数据文件。我希望用户更改数据,但磁盘上的文件保持不变。只有当用户单击“保存”时,才会更改磁盘上的数据文件。
In your opinion, what's the best way to do this?
在您看来,最好的方法是什么?
Should I load the contents of the SQLite DB into memory, maybe mapping it to objects, and write back to it when the user clicks "save"?
我应该将SQLite DB的内容加载到内存中,也可以将其映射到对象,并在用户单击“保存”时写回?
Or... is there a way to work with the data file with SQL commands (no objects), but leaving the changes in memory only, until "save" is clicked?
或者......有没有办法使用SQL命令(没有对象)处理数据文件,但只将更改保留在内存中,直到单击“保存”?
I'm a bit confused, I'd appreciate any idea regarding a best practice for this.
我有点困惑,我很欣赏任何关于最佳实践的想法。
Cheers
4 个解决方案