我正在努力让以下工作.我有一个包含Fields FirstName,LastName和DoctorId的表.我想使用Linq to SQL填充.net ListBox.这是我找到和借用的东西:
在一个我称为DALClass的课程中:
public List<Doctor> GetListDoctorsNames()
{
using (var db = new WaitListDataContext())
{
return (from c in db.Doctors
select new
{
FullName = c.FirstName + " " + c.LastName,
DoctorId = c.DoctorId
}
).ToList<Doctor>;
}
}
Run Code Online (Sandbox Code Playgroud)
该错误与").ToList;"有关.线.错误是:
错误1无法将方法组"ToList"转换为非委托类型"System.Collections.Generic.List".你打算调用这个方法吗?问:\ myapp\WaitList\App_Code\DALClass.cs 37 16问:\ myapp\WaitList \
我不确定我是不是应该放<String>而不是<Doctor>.我试过了,它不起作用.