Separating Webmatrix Queries into C# classes
The code below obviously won't work开发者_运维技巧. I am not familiar with how to return dynamically typed variables.
public class Db
{
public static var GetUsers()
{
var db = Database.Open("Db");
var sql = "SELECT FirstName FROM Users";
return db.Query(sql)
}
}
Use the dynamic keyword:
public static dynamic GetUsers()
{
var db = Database.Open("Db");
var sql = "SELECT FirstName FROM Users";
return db.Query(sql)
}
精彩评论