views:

48

answers:

1

I have ~10,000 records would like to keep in a collection in memory and execute LINQ queries against it. This collection should be available for all the users in the application domain and can access concurrently. I’m looking for a .NET collection that supports multithreading can query asynchronously and efficiently without any threading issues. Any suggestions on deciding a collection for this?

Sorry - It is only to read, no updates. And it should NOT be in .NET 4.0

+3  A: 

Do you need to update it? If not, any of the usual suspects (e.g. List<T> or an array) should be fine. If there's a natural key you want to look things up by, you may want to use a dictionary instead, but if it's really "just a collection" then a list should be fine.

EDIT: It looks like the rest of this answer is irrelevant to this particular question, but I'll leave it here for others with slightly different requirements.

If you do need to update it - and if you're able to use .NET 4 - you should at least consider ConcurrentBag. Bear in mind that it's unordered, and that if you iterate over it and modify the bag concurrently you won't see the changes (it's a snapshot, according to the docs), but if that's okay, it may well be what you're after.

If that doesn't quite do what you want, have a look at the other collections in the System.Collections.Concurrent namespace - again, this is all for .NET 4.

Jon Skeet