2

I have a server application written in C#.

As the application running, there will be tens of thousands of key->value mapping generated, and this info needs to be persisted. For each of these mapping records, there will be update/delete operation.

What is the best approach to store it? No database.

Is there any performance issue with ConfigurationManager in such case?

How about for thousands of records? Is it possible to avoid using any database?

Thanks!

Hardbone
  • 327
  • 1
  • 3
  • 16

5 Answers5

5

I know you said "No database", but consider the use of SQL Server Compact which provides a free, small-footprint SQL Server capability that you don't need to install - it's kind of like a grown up version of Jet.

Alternatively, you might want to see if you can find an ISAM implementation.

Steve Morgan
  • 12,978
  • 2
  • 40
  • 49
  • sql server compact is a good thing. for thens of thousands of records, please use a db instead of a flatfile – Michel Jul 29 '11 at 09:50
1

So you can always use XML for it. Or really use ConfigurationManager files (here is some example MSDN or here Loading custom configuration files)

Community
  • 1
  • 1
cnd
  • 32,616
  • 62
  • 183
  • 313
  • ConfigurationManager is easy to use. But I am not sure if any performance issue for it to handle large data. – Hardbone Jul 29 '11 at 09:54
  • @KeepWalking Configuration is XML too, so I don't think there could be much difference in performance. – cnd Jul 29 '11 at 09:55
  • If you're loading up many of these values at once, this might be a reasonable approach, but you'd be better off just using a flat-file in that case. Parsing an XML document to pick out a single value if going to be far from performant. – Steve Morgan Jul 29 '11 at 10:01
1

You may not be able to use a fully fledged database, but you could consider an embedded SQL Engine:

SQL Compact Edition or SQLLite

I've never used SQL CE, but SQLLite is just a single DLL.

Obviously you don't have all the features of a fully fledged database engine, but they are still pretty powerful and certainly much better than Configuration Manager for persisting data.

BonyT
  • 10,750
  • 5
  • 31
  • 52
1

Assuming the fact you're required to have no database by your hosting, there are still several options:

  1. SQL Server Compact approach when you just place your DB files under App_Data and use ADONET to get to those as if it was a fully functional SQL server.
  2. OLEDB connection to csv, dbf or any other structured file.
  3. Homegrown solution - something like an IDictionary<> collection persisted manually into an XML, flat file, binary array or whatever else.
Vitaly
  • 813
  • 10
  • 17
1

I agree with Steve Morgan. I recommend SQL Server Compact.

bluwater2001
  • 7,829
  • 5
  • 24
  • 21