c# - How to turn an IEnumerable (without type) into an IQueryable<T>? -
having used linq quite bit stumbling on basic task today:
having iqueryable<t>
out of ienumerable
(without type specified).
specifically want query on parameters of sqlparametercollection. deriving idataparametercollection, ilist, icollection, ienumerable
described here. however, these without type specified.
thus question boils down to: how use linq query on sqlparametercollection?
here's have done (the compiler did not complain):
iqueryable<sqlparameter> queryable = sqlcommand.parameters.asqueryable().cast<sqlparameter>(); //throws argumentexception "source not ienumerable<>"
note: have searched quite bit, talking ienumerable<t>
easy query using asqueryable()
of course.
i interested in reason why want this. should explained:
public iqueryable<t> asqueryable<t>(ienumerable list) { return list.cast<t>().asqueryable(); }
call this:
iqueryable<sqlparameter> query = asqueryable<sqlparameter>(sqlparametercollection);
Comments
Post a Comment