Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to save data locally in a WPF Application?

I'm building some WPF application to manage my time. I'd like to save time spans for work time on project for a calendar day.

So my question is what's the best choice on how to save the data? I figured I could use an XML file, an Access database file or maybe a property. I´d like to save the data locally, so no SQL Server action in this case. :)

What do you think, which way to go?

like image 640
Richard Avatar asked Nov 01 '09 19:11

Richard


People also ask

For which platforms can WPF applications be compiled?

WPF runtime libraries are included with all versions of Microsoft Windows since Windows Vista and Windows Server 2008.

Is WPF fast?

In general, WPF is perfoming much worse in drawing performance than Windows Forms, and native GDI or DirectX. Yes, WPF is powerful in the sense you might make some neat stuff that is not supported in GDI, but it is more sluggish.


2 Answers

I would grab SQLite either in its pure or a .NET-friendly form (doing a Google search for 'sqlite .net' will give you a few options there). It's super-portable and, in my opinion, easier to set up and distribute than SQL Server compact.

The important thing is to make sure you are not too tightly coupled to your persistence mechanism in your code, so in the future you could easily substitute any storage strategy you want.

like image 68
Adam Lear Avatar answered Sep 20 '22 00:09

Adam Lear


I know you said no SQL Server, but I am reading that to mean you want no "server", and you want to store your data on the client. I also assume you probably wouldn't mind some manageability of your data. You know, things like backup. And transactions are always nice, so your data can remain consistent. So, while you could use XML (please banish all thoughts of Access from your mind), you would end up rolling your own persistence, when this is a solved problem.

So, please check out the free SQL Server Compact edition. It is lightweight, designed to run on a desktop or mobile device, and is easily deployable if your app ever needs to do that. And all the common persistence frameworks support it. And have I mentioned it is free (as in costs nothing)?

like image 38
Jerry Bullard Avatar answered Sep 21 '22 00:09

Jerry Bullard