I have the following code.
public class Game
{
public string gamenumber { get; set; }
public string league { get; set; }
public string date { get; set; }
}
public class getGames
{
public List<Game> games { get; set; }
}
dt = mySQL.getAsDataTable("SELECT gamenumber, date, league FROM vSpiele WHERE gamenumber LIKE '" + sgamenumber + "'", null);
var getGames = new getGames
{
games = new List<Game>
{
new Game
{
gamenumber = dt.Rows[0]["gamenumber"].ToString(),
league = dt.Rows[0]["league"].ToString(),
date= dt.Rows[0]["date"].ToString(),
}
}
};
string json = JsonConvert.SerializeObject(getSpiele);
My output looks:
{
"Games": [{
"gamenumber": "123456",
"league": "Test League",
"date": "03.09.2016 15:00:00",
}]
}
My problem is that I need not only the line 0, I need all the lines of the table. I wanted to solve the problem actually with a for-loop but I always get an error. Does anyone have an idea how I come to the remaining data of the table?