Tuesday, November 01, 2005

Another geeky post.

We built our own query system several years ago.  It used the concept of "query by example" with templates that were interpreted into SQL.  You could generate the equivalent of an "IN" clause by assigning something that implemented System.Collections.ICollection to a template property.  Recently, with the introduction of generics and the generic collections, we decided to relax that contract to IEnumerable since that's really the least common denominator of all collections.  This produced some hilarious results.  As you can imagine, anywhere where we were using strings to specify template values, they were being interpreted as collections of characters.  This manifested itself mostly by having queries return nothing, since our system properly handled Chars and treated them as strings.

But, this reminded me of a similar incident a few years ago that involved a framework that rendered objects as comma-separated values. So, instead of:

Mark, Miller

You'd get:

M, a, r, k, M, i, l, l, e, r

I thought since I had been bitten twice, I would write it down.  I usually don't forget stuff I take the time to write down.

So, the moral of the story: Remember that even though System.String implements System.Collections.IEnumerable (and now System.Collections.Generic.IEnumerable<System.Char>), you usually don't want to treat it as a collection.  You may need to special-case it.

Anyone else think of another type like this?

posted on Tuesday, November 01, 2005 12:23:02 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
Related posts:
9-year Anniversary (yesterday)
LinqToStdf now on CodePlex
Image Slicer for Deep Zoom in Silverlight 2
Silverlight limitations and Constrained Callvirt in IL
Happy Birthday Peter
What are the generic Delegates in the framework for?
Tracked by:
"arizona fishing" (arizona fishing) [Trackback]
"oven baked beef back ribs" (oven baked beef back ribs) [Trackback]
"wellbutrin message board" (wellbutrin message board) [Trackback]
"Christine Dior Rings" (Christine Dior Rings) [Trackback]
"Weather Station" (Weather Station) [Trackback]
"closet pussy" (closet pussy) [Trackback]
"osteophytic disc ridging" (osteophytic disc ridging) [Trackback]
"emergency sleeping bag" (emergency sleeping bag) [Trackback]
"2004 bonneville gxp mod chip" (2004 bonneville gxp mod chip) [Trackback]
"Majorca Island" (Majorca Island) [Trackback]
"night guard" (night guard) [Trackback]
"used tractor" (used tractor) [Trackback]
"nitenpyram ingredients" (nitenpyram ingredients) [Trackback]
"oakland community college" (oakland community college) [Trackback]
"round folding tables" (round folding tables) [Trackback]
"pc troubleshooting" (pc troubleshooting) [Trackback]
"gean smith oil on canvas" (gean smith oil on canvas) [Trackback]
"eye candy for after iso download warez" (eye candy for after iso download warez... [Trackback]
"arkansas state parks" (arkansas state parks) [Trackback]
"Plavix Side Effects Reactions" (Plavix Side Effects Reactions) [Trackback]
"south carolina lottery" (south carolina lottery) [Trackback]
"Kit Car Manufacturers" (Kit Car Manufacturers) [Trackback]
"sunn mixer" (sunn mixer) [Trackback]
"deed search" (deed search) [Trackback]
"elliott claims group%2C llc" (elliott claims group%2C llc) [Trackback]
"used dive boats" (used dive boats) [Trackback]
"porches" (porches) [Trackback]
"pet umbrella" (pet umbrella) [Trackback]
"kidney sofa" (kidney sofa) [Trackback]
Name
E-mail
(will show your gravatar icon)
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):