Skip to content

Commit cb52431

Browse files
committed
chore(examples): add database and configure connection string
1 parent 31fdb2e commit cb52431

19 files changed

+1982
-1
lines changed
Binary file not shown.
Binary file not shown.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Kendo.Mvc.Extensions;
2+
using Kendo.Mvc.UI;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Web;
7+
using System.Web.Mvc;
8+
using Telerik.Examples.Mvc.Areas.GridAjaxBindingDatabase.Models;
9+
10+
namespace Telerik.Examples.Mvc.Areas.GridAjaxBindingDatabase.Controllers
11+
{
12+
public class HomeController : Controller
13+
{
14+
// GET: GridAjaxBindingDatabase/Home
15+
public ActionResult Index()
16+
{
17+
return View();
18+
}
19+
20+
public ActionResult Products_Read([DataSourceRequest] DataSourceRequest request)
21+
{
22+
using (var sample = new SampleEntities())
23+
{
24+
IQueryable<Product> products = sample.Products;
25+
DataSourceResult result = products.ToDataSourceResult(request);
26+
return Json(result);
27+
}
28+
}
29+
}
30+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.Web.Mvc;
2+
3+
namespace Telerik.Examples.Mvc.Areas.GridAjaxBindingDatabase
4+
{
5+
public class GridAjaxBindingDatabaseAreaRegistration : AreaRegistration
6+
{
7+
public override string AreaName
8+
{
9+
get
10+
{
11+
return "GridAjaxBindingDatabase";
12+
}
13+
}
14+
15+
public override void RegisterArea(AreaRegistrationContext context)
16+
{
17+
context.MapRoute(
18+
"GridAjaxBindingDatabase_default",
19+
"GridAjaxBindingDatabase/{controller}/{action}/{id}",
20+
new { action = "Index", id = UrlParameter.Optional }
21+
);
22+
}
23+
}
24+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated from a template.
4+
//
5+
// Manual changes to this file may cause unexpected behavior in your application.
6+
// Manual changes to this file will be overwritten if the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
namespace Telerik.Examples.Mvc.Areas.GridAjaxBindingDatabase.Models
11+
{
12+
using System;
13+
using System.Collections.Generic;
14+
15+
public partial class Product
16+
{
17+
public int ProductID { get; set; }
18+
public string ProductName { get; set; }
19+
public Nullable<int> SupplierID { get; set; }
20+
public Nullable<int> CategoryID { get; set; }
21+
public string QuantityPerUnit { get; set; }
22+
public Nullable<decimal> UnitPrice { get; set; }
23+
public Nullable<short> UnitsInStock { get; set; }
24+
public Nullable<short> UnitsOnOrder { get; set; }
25+
public Nullable<short> ReorderLevel { get; set; }
26+
public bool Discontinued { get; set; }
27+
}
28+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated from a template.
4+
//
5+
// Manual changes to this file may cause unexpected behavior in your application.
6+
// Manual changes to this file will be overwritten if the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
namespace Telerik.Examples.Mvc.Areas.GridAjaxBindingDatabase.Models
11+
{
12+
using System;
13+
using System.Data.Entity;
14+
using System.Data.Entity.Infrastructure;
15+
16+
public partial class SampleEntities : DbContext
17+
{
18+
public SampleEntities()
19+
: base("name=SampleEntities")
20+
{
21+
}
22+
23+
protected override void OnModelCreating(DbModelBuilder modelBuilder)
24+
{
25+
throw new UnintentionalCodeFirstException();
26+
}
27+
28+
public DbSet<Product> Products { get; set; }
29+
}
30+
}

0 commit comments

Comments
 (0)