Hello,
this code is working fine
@{
var db = Database.Open("bakery");
var products = db.Query("SELECT * FROM PRODUCTS").ToList();
}
@foreach (var p in products) {
@p.Name<br>
}
I just would like anyway to move the creation of products together with the db opening into an helper file or function file.
From my Default.cshtml I just want to cycle on my variables, while I would like to keep the creation of the lists in a separate file (App_Code folder) which has all the functions and where the database connection is handled.
How do I do it? Suggestions?
Thank you
this code is working fine
@{
var db = Database.Open("bakery");
var products = db.Query("SELECT * FROM PRODUCTS").ToList();
}
@foreach (var p in products) {
@p.Name<br>
}
I just would like anyway to move the creation of products together with the db opening into an helper file or function file.
From my Default.cshtml I just want to cycle on my variables, while I would like to keep the creation of the lists in a separate file (App_Code folder) which has all the functions and where the database connection is handled.
How do I do it? Suggestions?
Thank you