|
[index.cshtml]
<ej-grid id="FlatGrid" datasource="ViewBag.datasource" allow-paging="true" >
<e-columns>
<e-column field="OrderID" header-text="Order ID" text-align="Right" width="75" is-primary-key="true"></e-column>
<e-column field="CustomerID" header-text="Customer ID" width="80"></e-column>
<e-column field="EmployeeID" header-text="EmployeeID" width="80"></e-column>
<e-column field="Verified" header-text="Verified" width="110"></e-column>
</e-columns>
</ej-grid>
[Homecontroller.cs]
namespace WebApplication1.Controllers
{
public class HomeController : Controller
{
private NORTHWNDContext _context;
public HomeController(NORTHWNDContext context)
{
_context = context;
}
public IActionResult Index()
{
ViewBag.datasource = _context.Orders.ToList();
return View();
}
[NORTHWNDContext.cs]
namespace WebApplication1.Models
{
public partial class NORTHWNDContext : DbContext
{
public NORTHWNDContext(DbContextOptions<NORTHWNDContext> options)
: base(options)
{ }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Orders>(entity =>
{
entity.Property(e => e.OrderID).IsRequired();
});
modelBuilder.Entity<Employees>(entity =>
{
entity.Property(e => e.EmployeeID).IsRequired();
});
}
public virtual DbSet<Orders> Orders { get; set; }
public virtual DbSet<Employees> Employees { get; set; }
}
}
|