using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
[WebMethod]
public static string GetData(string json, string sortExpressionsAsSQL)
{
DataTable dt = new DataTable();
try
{
dt = JsonConvert.DeserializeObject<DataTable>(json);
if (dt.Rows.Count > 0)
{
dt.DefaultView.Sort = sortExpressionsAsSQL;
dt = dt.DefaultView.ToTable();
return JsonConvert.SerializeObject(dt, Newtonsoft.Json.Formatting.Indented);
}
else { return "[]"; }
}
catch (Exception) { return "[]"; }
finally { dt.Dispose(); dt.Clear(); }
}
using Newtonsoft.Json.Linq;
[WebMethod]
public static string GetData(string json, string sortExpressionsAsSQL)
{
DataTable dt = new DataTable();
try
{
dt = JsonConvert.DeserializeObject<DataTable>(json);
if (dt.Rows.Count > 0)
{
dt.DefaultView.Sort = sortExpressionsAsSQL;
dt = dt.DefaultView.ToTable();
return JsonConvert.SerializeObject(dt, Newtonsoft.Json.Formatting.Indented);
}
else { return "[]"; }
}
catch (Exception) { return "[]"; }
finally { dt.Dispose(); dt.Clear(); }
}
No comments:
Post a Comment