?
Solved

Pros and Cons of List vs Dictionary for in-memory proxies of DB Tables

Posted on 2014-01-01
2
Medium Priority
?
276 Views
Last Modified: 2014-01-05
I've got an ASP.NET app that currently uses DataSets and TableAdapters, and thus makes heavey use of typed DataRows.

I'm going to convert this to Connected Data Access as described here:

http://msdn.microsoft.com/en-us/data/ff707264.aspx#_Toc261428884

(FYI, I'm not going with anything more abstract, like Entity Framework, in order to maintain migratability)

The example at that link uses Lists as in-memory proxies for the DB tables.

I recently learned that Dictionaries can be searched much faster that Lists, for unique IDs, which I can arrange for have in all the tables I'm using.  Also, Dictionaries can be Typed.

What I'm hoping for is input on the Pros and Cons of List vs Dictionary for these in-memory proxies of DB Tables.

Any help with this would be appreciated.

Thanks!
0
Comment
Question by:codequest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
Stephan earned 2000 total points
ID: 39751043
These are a few things that I know about Lists and Dictionaries

Pros dictionary:
Has the smallest memory print
is faster when they have a large set of data

Cons dictionary:
Dictionaries don't have any sort capability

Pros list:
Is faster depending on the field (e.g. string value is faster in lists than dictionaries)
Lists are in a way sorted on insertion

Cons list:
It is getting really slow when the set if data is getting bigger

Big thing between lists and dictionaries is that dictionaries has it's on hash table for the keys. For example, integers are way faster than string values on a hash table.

So I think it really depends on what you want to do with the data.
Most people prefer Lists because there are more flexible because you don't need a key.
But on performance and memory it is recommended to use a Dictionary but it depends what you want to do exactly.

Here is a blog post that takes a quick look at "HashSet vs List vs Dictionary"
http://theburningmonk.com/2011/03/hashset-vs-list-vs-dictionary/
0
 
LVL 2

Author Comment

by:codequest
ID: 39756385
Thanks for input.  Good info.   I'll think on this, see if there are other responses, then close out.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question