@model IEnumerable<dbMVC.Models.test> @{ ViewBag.Title = "Home Page"; } <h2>View1</h2> @foreach (var item in Model) { <h2>@item.idt @item.datetime @item.col1 @item.col2 @item.col3</h2> }
using dbMVC.Models; using System.Data.Entity; namespace dbMVC.Controllers { public class TestDataController : Controller { // // GET: /TestData/ private DataContext db = new DataContext(); public ActionResult DataIndex() { var dataout = from test in db.Data1 select test; return View(dataout); } } }
using System.Data.Entity; using dbMVC.Models; namespace dbMVC.Models { public class DataContext : DbContext { //enables CRUD public DbSet<test> Data1 { get; set; } } }
namespace dbMVC.Models { public class test { public int idt { get; set; } public string datetime { get; set; } public string col1 { get; set; } public string col2 { get; set; } public string col3 { get; set; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)