tags:

views:

80

answers:

3

What I want to do is:

  • Load values for a program from a file.
  • Read/Add/Change those values.
  • Save those values back to the file
  • I would like to be able to have a database be the file
  • I want as much of the data as possible to stay in memory, so I'm not hammering the file
  • I would like to query using Linq or be able to use a Standard Query Language
  • I want the data returned as arrays of objects

I figure there has be to something like this out there. Sort of like the backed of the GAE but for C# and local applications.

I'm looking for names for this kind of data interaction and projects, preferably free with non infectious and crushing licensing, to help build my understanding and use of the concept.

A: 

You want an XML document which you access easily using Linq to XML.

XDocument.Load(memoryStream)

And you're on your way.

Jimmy Hoffa
LINQ to XML would use `XDocument`.
Steven Sudit
Duh, I don't know why I said XmlDocument.. I use LINQ to XML all the damne time, stupid brain something something..
Jimmy Hoffa
+1  A: 

The right way to do this depends on the amount of data you have and how you need to access it.

You could just use an XML file and Linq-to-XML if you're really just talking about some kind of configuration file which could all be in memory at once.

If you're talking about lots of data, then you could look at a database like Sqlite or SQL Server Express or SQL Server Compact Edition.

Will Dean
+1  A: 

Given your requirements, I would recommend looking at Entity Framework. It meets nearly all of your query/update requirements, and works with many databases.

For a single file database that works with EF, you might want to consider SQL Server CE. Version 4 is in beta currently, and handles your single file, mostly in memory, etc. requirements well.

The only thing is that, using LINQ with EF, you'll get your objects out as either IQueryable<T> or IEnumerable<T>, typically not as arrays. You can always call .ToArray() on these to convert into an array, but this is typically not necessary.

Reed Copsey