I can run sql doing the following on a page:
var db = Database.Open("DefaultConnection");
var selectBrands = db.Query("SELECT DISTINCT SubDescription1 AS Brands FROM dbo.Item");
@foreach (var row in selectBrands )
What I want to do is run the sql query within a function in a class. The function will return the data which I am trying to iterate through. I have attached text file with the code.
I get the following error:
Error 19 'object' does not contain a definition for 'Brands' and no extension method 'Brands' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
What I am trying to do is separate markup from logic by setting up classes, is this the right way of going about it?