Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# jQuery Ajax MVC4应用程序_C#_Jquery_Ajax_Asp.net Mvc - Fatal编程技术网

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()”的类型参数。尝试显式指定类型参数。好吧,我在控制器中遇到了这个错误,我还没有创建视图,这给了我一个错误