jQuery Ajax MVC 4应用程序
本文关键字:应用程序 MVC Ajax jQuery | 更新日期: 2023-09-27 18:08:41
我正在关注ASP中的Ajax和jQuery的博客。净MVC
My Model Class:
namespace Chekout.Models
{
[Table(Name = "Products")]
public class Product
{
[Column(IsPrimaryKey = true)]
public int Id { get; set; }
[Column]
public string Name { get; set; }
[Column]
public string Description { get; set; }
[Column]
public decimal Price { get; set; }
[Column]
public int UnitsInStock { get; set; }
}
}
我的控制器:
namespace Chekout.Controllers
{
public class ProductController : Controller
{
//dbContextDataContext is my dbml class which was not generated in the blog.
dbContextDataContext dbContext = null;
public ProductController()
{
this.dbContext = new dbContextDataContext(Connection.connectionString);
}
//
// GET: /Product/
public ActionResult Index()
{
//Products[] product = dbContext.GetTable().ToArray();
//The Above Statement gives me Error! Why? Am i not following the blog?
return View();
}
}
}
我想选择,更新,插入,删除数据通过jquery ajax在MVC应用程序。我一直在关注上面的博客,但这对我没有帮助。请说明我做错了什么,或者我没有关注博客。
因为编译器不能推断出你想要获取的对象类型,所以你必须指定它。例如:
Products[] product = dbContext.GetTable<Products>().ToArray();