

Cast method itself returns an IEnumerable. Also bear in mind that, as I said before there's no real benefit in casting to dynamic As of now you're merely assigning method reference to a variable And preferably execute the resulting query. The reader is typically closed in the method. able to get data once the reader or connection is closed.

If you simply assign reader object itself as the data you wont be

You have to loop the reader to get the values from it. Please note this is a simplified example, and while the reason for the two query types is not obvious, they are necessary in my code. I'm looking for the best way to get the reader object to a IEnumerable object. Error: 'Cannot convert method group "Cast" to non-delegate type "dynamic". Error in view, 'Invalid attempt to call FieldCount when reader is closed' (on 'var row `in` Model.Data') Here's all the different things I've tried from reading various other posts: // Atempt 1 OdbcDataReader reader = command.ExecuteReader() OdbcCommand com = new OdbcCommand("Select * From " + table) Ĭommand.CommandType = Using (OdbcConnection con = ne4w OdbcConnection(ConString)) db = new () ĭata = db.Query("SELECT * FROM " + table) I have a View that typically gets query results from a WebMatrix Query ( IEnumerable data type), and displays the results in a table: row in (var column in my model where I query the database: public class Entity
