I have a background in PHP and bump into a problem while trying out ASP.NET webAPI.
I have a MySQL database and a table that contains some files information. Now i want to make a "SELECT * FROM Files" and see the result in XML.
How can i render the result of the query that is returned?
This is my code at the moment,
The Model:
namespace ProductsApp.Models
{
public class File
{
public int Id {get; set;}
public string Text {get; set;}
}
}
The Controller:
public IEnumerable<File> Get()
{
try
{
command = conn.CreateCommand();
command.CommandText = "SELECT * FROM Files";
conn.Open();
MySqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
//How to output the rows ????
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return null; // return the list
}