=ts=
=html=
=controller=
產生nested tree json
[System.Web.Http.HttpGet]
[System.Web.Http.Route("api/SaInvoice/WebApTreeView")]
public HttpResponseMessage WebApTreeView()
{
try
{
DynamicParameters parameter = new DynamicParameters();
string SqlString = " ";
//parameter.Add(":F_KEY_NO", queryParm.F_KEY_NO);
var data = this.db.Query(SqlString).ToList();
var result = from a in data
where a.TREE_F_KEY == null
orderby a.CODE
select new
{
a.KEY_NO,
a.F_KEY_NO,
a.TREE_KEY,
a.TREE_F_KEY,
a.CODE,
a.DESCRP,
childern = from b in data
where a.TREE_KEY == b.TREE_F_KEY
orderby b.CODE
select new
{
b.KEY_NO,
b.F_KEY_NO,
b.TREE_KEY,
b.TREE_F_KEY,
b.CODE,
b.DESCRP,
childern = from c in data
where b.TREE_KEY == c.TREE_F_KEY
orderby c.CODE
select new
{
c.KEY_NO,
c.F_KEY_NO,
c.CODE,
c.DESCRP
}
}
};
return Request.CreateResponse(HttpStatusCode.OK, result);
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
}
}
留言列表