我正在尝试使用 Linqtosql 显示来自我的数据库的列表,但我想我做错了。
如果您需要更多信息,我编写了 SPROC 以在此处检索数据:这是我的代码:
protected List<MySubject> GetSubjects(int userID, string Datetime)
{
userID = user_id;
string[] dates = Datetime.Split('-');
int year = int.Parse(dates[2]);
int month = int.Parse(dates[1]);
int day = int.Parse(dates[0]);
ClassDAO classClass = new ClassDAO();
List<MySubject> myTodaySubjects = GetSubjectsLinq(userID, day);
GetSubjectsLinq(userID, day);
return myTodaySubjects;
}
private List<MySubject> GetSubjectsLinq(int UserId, int day)
{
MySchoolDBDataContext db = new MySchoolDBDataContext();
string Suserid = UserId.ToString();
string Sday = day.ToString();
var sub = db.GetSubjects(Sday , Suserid);
return sub.ToList<MySubject>();
}
此行"return sub.ToList<MySubject>();"
显示此错误:
Error 21 Instance argument: cannot convert from
'System.Data.Linq.ISingleResult' to 'System.Collections.Generic.IEnumerable'.
你知道我该如何解决吗?