I followed this tutorial (http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api) for setting up a Web API in my ASP.NET Web Application. It doesnt, however, talk about how to retrieve records from a database. It instead hard coded dummy data into the controller, like this:
Product[] products = new Product[]
{
new Product { Id = 1, Name = "Tomato Soup", Category = "Groceries", Price = 1 },
new Product { Id = 2, Name = "Yo-yo", Category = "Toys", Price = 3.75M },
new Product { Id = 3, Name = "Hammer", Category = "Hardware", Price = 16.99M }
};
Let's say I have a table in my SQL DB called 'Products', how would I retrieve the product data from there instead? If anyone could point me in the right direction, I would appreciate it.
I did try using a function but it didnt work.
DataTable dbProducts = new DataTable();
dbProducts = Wrapper.getProducts();