<summary>
生成json数据
</summary>
<param name="query"></param>
<returns></returns>
private string BuildJsonForOrganization(IQueryable<Organization> query)
{
StringBuilder Json = new StringBuilder();
if (query.Count() > 0)
{
Json.Append("[");
int index = 0;
foreach (Organization org in query)
{
Json.Append("{");
Json.Append("id:" + org.Id + ",");
Json.Append("pid:" + org.ParentId + ",");
Json.Append("name:\"" + org.OrgName + "\",");
Json.Append("smalltype:\"" + org.OrgSmallType + "\",");
Json.Append("code:\"" + org.Code + "\"");
if (org.ParentId == 0)
{
Json.Append(",expanded:true");
}
if (index < query.Count() - 1)
{
Json.Append("},");
}
else
{
Json.Append("}");
}
index++;
}
return Json.ToString() + "]";
}
return Json.ToString();
}