开发者

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)
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜