我正在尝试使以下工作。我有一个包含字段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>;
}
}
该错误与“).ToList;”有关 线。错误是:
错误 1 无法将方法组“ToList”转换为非委托类型“System.Collections.Generic.List”。您是否打算调用该方法?Q:\myapp\WaitList\App_Code\DALClass.cs 37 16 Q:\myapp\WaitList\
我不确定我是否应该把<String>
而不是<Doctor>
. 我已经尝试过了,但它不起作用。