I have created a database entity to an existing SQL DB.
But query does not return the data I am expecting
namespace WebApplication5.Controllers
{
public class EmployeeController : Controller
{
// GET: Employee
public ActionResult Index()
{
List<string> orderIDs = new List<string>();
using (var db = new WebApplication5.Models.BTP_NYAEntities())
{
var query = from b in db.FilledOrders
select b;
//Console.WriteLine("All blogs in the database:");
foreach (var item in query)
{
//Console.WriteLine(item.OrderID);
orderIDs.Add(item.OrderID.ToString());
}
}
ViewData["MyData"] = orderIDs;
return View(orderIDs);
}
}
}
View:
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Employee Index Page</title>
</head>
<body>
<div>
<h1>Employee Index Page</h1>
@{
var categories = (List<string>)ViewData["MyData"];
foreach(var item in categories)
{
<p>This is a test emp index page @item</p>
}
}
</div>
</body>
</html>
BTP_NYAEntities. Read over MCVE so that you know what to include in your question next time.BTP_NYAEntitiesin the same MVC project or separate one? Also try searching across solution with that name. If you can find then, check thenamespacedefined in that file above class name and use that namespace withusing MyNamespace;on top of file where you want to use it.