我有需要在页面加载时填充的列表以下是 dal 中的代码
public List<KeyValuePair<Guid, string>> GetProjectName()
{
List<KeyValuePair<Guid, string>> List = null;
try
{
using (LiveLeaseEntities db = LiveLeaseHelper.GetDbLiveLeaseEntities())
{
var projects = (from p in db.t_Project
where p.IsActive == true
select p).ToList();
if (projects != null)
{
foreach (t_Project p in projects)
{
List.Add(new KeyValuePair<Guid, string>(p.ProjectId, p.ProjectName));
}
}
return List;
我得到对象未设置为对象错误的实例。逐步完成项目显示计数为 7,但出现错误。