I need to use Linq on any IDataReader implementations like this
var c = sqlDataReader.AsEnumerable().Count();
Example:
<
You could create an extension method to do this (see caveats below):
public static class DataReaderExtension
{
public static IEnumerable
Found here: http://www.thinqlinq.com/default/Consuming-a-DataReader-with-LINQ.aspx
As pointed out by @LukeH, note that as IDataReader only supports reading once, forwards, you'll only be able to query the enumerable once. (To get round this you could call ToList/ToArray, then query that).
Note that SqlDataReader
already impliments IEnumerable so you won't need to do this in the example you've given.
Also, be aware that it's probably better to do any filtering/aggrigating on the server (via LINQ to SQL for example)