views:

55

answers:

2

I have a WPF application that stores a large amount of information in XML files and as the user uses the application they add more information to the XML files. It's basically using the XML files as a database. Since over the life of the program the XML files have gotten quite large, and I've been think about putting the data on a website, I've been looking into how to move all the information into an SQL database.

I've used SQL databases with web applications (PHP, Ruby, and ASP.NET) but never with a Desktop application. Ideally I'd like to be able to keep all the information in one database file and distribute it along with the application without requiring the user to connect to a remote database (so they don't need an internet connection - though eventually it would be nice if could compare the local file's version with one online somewhere and update if necessary) and without making them install a local database server on their computer. Is this possible?

I'd also like to use LINQ with any new database solution so switching to a database doesn't force to many changes (I read the XML with LINQ).

I'm sure this question has been asked and that there are already some good tutorials on the subject but I just can't find them.

+1  A: 

SQLite is a good embedded database that you can ship along with your application. I have not done much more than some prototyping with it, so I personally cannot say with 100% certainty that it will meet your needs. But from what I have read, and what little I have written against it, it seems appropriate for the job.

SQLite Homepage

ADO.NET Provider

Rob Goodwin
Guess this should be a whole new question, and is probably silly, but how do ADO.NET and LINQ fit together? I was under the impression LINQ was a newer database access layer meant to replace ADO.NET, or is LINQ compatible with ADO.NET? Thanks, and thanks for suggesting SQLite!
evan
http://msdn.microsoft.com/en-us/library/bb399365.aspx
Rob Goodwin
With [System.Data.SQLite](http://sqlite.phxsoftware.com/) you can either use Linq-To-Sql or Linq-To-Entities. I have used SQLite with Entity Framework in my recent project and it has worked absolutely superbly. For local desktop app's needs it's absolutely great. No db server installation, no fuss. I have even run some internal tests and with about ~300K of identical rows, SQLite outperformed SQL Server 2008 Express by 2.5x - 3x on some queries.
wpfwannabe
A: 

If you know how your objects are all going to fit together, you could serialize them/deserialize them to store them on disk as a set of ProtoBuf objects (depending on their size, of course). I've found that it's a pretty simple, elegant solution to storing a set of interconnected classes. Each class that should be savable, all your data, can be serialized using this method, and then restored as necessary.

Here's the .NET link to it.

This is a previous question I asked on SO, and got several good responses.

mmr