【发布时间】:2016-07-10 19:02:17
【问题描述】:
所以我正在尝试通过本指南学习 ASP.net、AJAX、Json 和 JQuery: http://www.search-this.com/2010/04/26/asp-net-linq-jquery-json-ajax-oh-my/#
但是我什至无法让第一段代码工作。
public class CourseReservations
{
public long CourseId { get; set; }
public string Course { get; set; }
public string Time { get; set; }
public int Holes { get; set; }
public int Golfers { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
[WebMethod]
public List<CourseReservations> GetGolfCourseReservations()
{
using (DataContext dc = new DataContext()) // Creating the Error, it says that I can't have a DataContext constructor that takes 0 arguments... I am just questioning how this code can work for him then??
{
var query = from res in dc.GolfReservations // I get an Error here too, saying there is no definition for GolfReservations
where res.CourseId == 1
select new CourseReservations
{
CourseId = res.CourseId,
Course = res.GolfCourse.CourseName,
Time = res.DataAndTime.ToShortTimeString(),
Holes = res.Holes,
Golfers = res.Golfers,
FirstName = res.Aspnet_User.GolfUser.FirstName,
LastName = res.Aspnet_User.GolfUser.LastName,
};
return query.ToList();
}
}
希望有人能提供帮助!
【问题讨论】:
-
你的 DataContext 是什么样的?
-
等等,除了这段代码我什么都没有……我对数据库和所有的一切都是全新的。我该怎么办?
标签: c# jquery asp.net json ajax