递归一个组织机构表里的所有组织机构,将组织机构ID拼接成组织机构串。我在调试时,在拼接完成后,return 了,又跑回来执行了3次 “GetOrgPath(orgBll.GetParentOrg(orgid).OrgId, orgFullPath);” 导致结果不是我想要的。没想明白,求解答,代码见下:
public string GetOrgPath(int orgid,string orgpath)
{
string orgFullPath = String.Empty;
orgFullPath = orgFullPath + orgpath;
if (orgBll.GetModel(orgid).ParentOrgId != 0)
{
orgFullPath = orgFullPath + orgBll.GetParentOrg(orgid).OrgId.ToString()+"/";
GetOrgPath(orgBll.GetParentOrg(orgid).OrgId, orgFullPath);
}
return orgFullPath;
}