C# jQuery Ajax MVC4应用程序
我在关注一个博客 我的模型课:C# jQuery Ajax MVC4应用程序,c#,jquery,ajax,asp.net-mvc,C#,Jquery,Ajax,Asp.net Mvc,我在关注一个博客 我的模型课: namespace Chekout.Models { [Table(Name = "Products")] public class Product { [Column(IsPrimaryKey = true)] public int Id { get; set; } [Column] public string Name { get; set; } [Colu
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();
}
}
}
我想在MVC应用程序中通过jQueryAjax选择、更新、插入和删除数据。我一直在关注上面的博客,但这对我没有帮助。请指定我做错了什么,或者我没有关注博客。因为编译器无法推断您要获取的对象类型,所以必须指定它。例如:
Products[] product = dbContext.GetTable<Products>().ToArray();
Products[]product=dbContext.GetTable().ToArray();
更多详细信息。您会遇到什么错误?您的看法如何?您是否错过了一些简单的操作,如将jquery包含为引用?我收到此错误。无法从用法推断方法“System.Data.Linq.DataContext.GetTable()”的类型参数。尝试显式指定类型参数。好吧,我在控制器中遇到了这个错误,我还没有创建视图,这给了我一个错误