0

How do I check to see if the ObjectResult<> has a value or not? Right now it's returning values but will it throw an exception is there is nothing to return?

This is the section of code that I need to check so I do not have to depend on a try catch block


iProjInfo.ProjectLeafs = db.proc_GetProjectLeafs(projectID).ToList<IProjectLeafs>();

public static Task<IProjectInfo> GetProjectInfo(int projectID)
{
    return Task.Run(() =>
      {
          using (var db = new StorefrontSystemEntities())
          {
              IProjectInfo iProjInfo = db.proc_GetProject_ForDrawings(projectID).Single<IProjectInfo>();

              try
              {
                  iProjInfo.ProjectLeafs = db.proc_GetProjectLeafs(projectID).ToList<IProjectLeafs>();
              }
              catch (Exception ex)
              {

              }
              return iProjInfo;
          };
      });
}
4

1 回答 1

0

只要存储过程正在执行并返回结果集;即使它是空的(存储过程没有返回记录),您也可以确定返回的是一个空列表。

于 2013-07-29T01:06:17.527 回答