-2
所以我想學ASP.net,AJAX,JSON和JQuery本指南: http://www.search-this.com/2010/04/26/asp-net-linq-jquery-json-ajax-oh-my/#錯誤創建一個DataContext實例
但是我甚至不能獲得代碼的第一位工作。
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是什麼樣的? –
等一下,我沒有別的東西比這個代碼...我完全是數據庫和所有新手。我該怎麼辦? – coding4life