C
Chuck P
I want to get a DataReader from a Linq Query so I wrote this Extension Method
public static IDataReader QueryToDataReader(this
System.Data.Linq.DataContext ctx, object query)
{
IDbCommand command = ctx.GetCommand(query as IQueryable);
command.Connection = ctx.Connection;
command.Connection.Open();
IDataReader reader =
command.ExecuteReader(CommandBehavior.CloseConnection);
return reader;
}
Sometimes it pukes because the Query passed in is a Type
System.Collections.Generic.IEnumerable<Application>
not an IQueryable.
Query comes back as a IEnumerable when I call a sproc that returns after a
select statement, even though the return type is defined in the datacontext.
If my sproc returns a TABLE object, the Query comes back as a IQueryable.
I don't understand why I get IEnumerable sometimes and IQueryable others?
Is their a way to get my function to work in both cases?
public static IDataReader QueryToDataReader(this
System.Data.Linq.DataContext ctx, object query)
{
IDbCommand command = ctx.GetCommand(query as IQueryable);
command.Connection = ctx.Connection;
command.Connection.Open();
IDataReader reader =
command.ExecuteReader(CommandBehavior.CloseConnection);
return reader;
}
Sometimes it pukes because the Query passed in is a Type
System.Collections.Generic.IEnumerable<Application>
not an IQueryable.
Query comes back as a IEnumerable when I call a sproc that returns after a
select statement, even though the return type is defined in the datacontext.
If my sproc returns a TABLE object, the Query comes back as a IQueryable.
I don't understand why I get IEnumerable sometimes and IQueryable others?
Is their a way to get my function to work in both cases?