コード例 #1
0
    public static List <Category> GetCategories()
    {
        List <Category> currentCategories = new List <Category>();

        DbCommand comm = GenericDataAccess.CreateTextCommand();

        comm.CommandText = "SELECT Id, Name FROM Categories Order By Name";
        DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);

        foreach (DataRow row in table.Rows)
        {
            Category cat = new Category();
            cat.Id   = int.Parse(row["Id"].ToString());
            cat.Name = row["Name"].ToString();
            currentCategories.Add(cat);
        }
        return(currentCategories);
    }