People are still using dr[stringName], when dr[intOrdinal] is soooooo much faster.
Sorry in advance Plip, I'm not targeting your code, I'm writing this more as a general performance rant. Plip writes in his article on how to load strongly typed data Part 3: Using Strongly Typed Objects and Collections to replace DataSet’s in your .NET applications. I only have one problem with his approach, he makes the mistake of using a string ordinal look-up. Let me tell you what is involved with a string ordinal look-up. First time through, you have to create a FieldNameLookup object. This takes a bit of time as it loads all of the meta-data off of the reader to build your look-up table. Once that is built, the string is used to look into that table. This involves a bunch of null checks, a hashtable look-up, etc.., etc..., you get the point. This crap is slow.
What are the alternatives? Well, for development, I say leave it as is. However, after development is done and the SP is locked down in terms of column ordinals in the returned data, you are going to replace that string name with an enumeration. Enumerations give you all the power of having a string based name right there that you can see but at the same time index into the data reader much more quickly than a string. I originally made this change to the ASP .NET Forums system when upgrading it for V2 back in February of 2003. The resulting performance increase and throughput measured on average 3-4% and as much as 7%. That is pretty huge. At that time the system was extremely data-bound and we were doing thousands of look-ups into that FieldLookupTable to render just a single view.
Want another alternative? Well, you can cache the ordinals for all of your fields the first time through. That is, if you want that level of flexibility. You might wind up with a string[] of each field, and an int[] that stores the ordinal after look-up, then use that to index. I just can't see where this is more powerful than the enumeration method since it has slightly degraded performance and there is an implementation detail with how you store the cached look-up data.