所以我正在尝试使用本指南学习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();
}
}
希望有人可以提供帮助!
答案 0 :(得分:0)