Returning IEnumerable from an indexer, bad practice?

Posted by fearofawhackplanet on Stack Overflow See other posts from Stack Overflow or by fearofawhackplanet
Published on 2010-03-25T12:50:18Z Indexed on 2010/03/25 12:53 UTC
Read the original article Hit count: 547

Filed under:
|
|

If I had a CarsDataStore representing a table something like:

Cars
--------------
Ford | Fiesta
Ford | Escort
Ford | Orion
Fiat | Uno
Fiat | Panda

Then I could do

IEnumerable<Cars> fords = CarsDataStore["Ford"];

Is this a bad idea? It's iconsistent with the other datastore objects in my api (which all have a single column PK indexer), and I'm guessing most people don't expect an indexer to return a collection in this situation.

© Stack Overflow or respective owner

Related posts about c#

Related posts about indexer