views:

91

answers:

4

Are there any classes that can be queried / modified like a SQL DB but is entirely local and internal to the program?

I am aiming to write a program that needs to have a local data source with all data saved in a file, but I would like to be able to query this information store just as I would a DB; LINQ compatibility would be a huge plus.

The data would only be accessible when the program was running meaning, there would be no other process running to serve the data such as SQL server.

+1  A: 

XML comes to mind. I am not sure if you are trying to actually save the data to a file or if you want to keep it entirely in memory. But with XML you can use LINQ to XML for your querying and it's got good structure, easy to save out to a file, etc.

Tim C
Certainly XPath (and, to a degree, XSLT) give powerful query features... albeit a very different model to a conventional database.
Richard
+4  A: 

You could use SQLite with DBLinq.

Mark Byers
+5  A: 

You can use SQL Server Compact Edition. It is hosted in-process and uses a .sdf file locally. It works with LINQ and the LINQ-to-SQL designer. To use it, you'll just need to add a reference to System.Data.SqlServerCe.dll. It's very lightweight, familiar, and has excellent support in Visual Studio.

On a side note, the Visual C++ IDE team is using this database for their C++ IntelliSense information in Visual Studio 2010, replacing the old .ncb files. Based on their stated goals going into the project (rewriting the C++ IDE for massively improved IntelliSense performance and stability), seeing it used here says a lot.

280Z28
+1: This is probably a better suggestion than mine. I didn't realize this product was free.
Mark Byers
+1  A: 

DataSets allow multiple tables of data to be held and processed in memory.

LINQ to DataSets is part of .NET 3.5: http://msdn.microsoft.com/en-us/library/bb386977.aspx

This would allow a custom storage format, if you write the serialisation and deserialisation to a DataSet for your format.

If you don't want to create your own file format, SQL Server Compact Edition (or SQL Express) would probably be an easier option (as in other answer).

Richard