本帖最后由 郑丹丹1990 于 2013-4-5 18:51 编辑
private DepartMent ToDeptMent(DataRow row)
{
DepartMent dept = new DepartMent();
dept.Id = (Guid)row["Id"];
dept.Name = (string)row["Name"];
dept.IsStopped = (bool)row["IsStopped"];
return dept;
}
public List<DepartMent> GetByDept()
{
DataTable dt = SqlHelper.GetDataTable("select * from dbo.T_Department ");
List<DepartMent> deptList = new List<DepartMent>();
for (int i = 0;; i++)
{
if (dt.Rows != null)//当i=6时,数据库中已经没有数据,应该会break,但当程序走到此处,执行 deptList.Add(ToDeptMent(dt.Rows));???????
{
deptList.Add(ToDeptMent(dt.Rows));
}
else
{
break;
}
}
return deptList;
} |