public String ExecuteQueryJson(int QuestionId, String Query, int UserId)
 {
     try
     {
         var db      = new Database(_da);
         var results = db.ExecuteUserQuery(QuestionId, Query, UserId);
         var dtModel = DataTableModelHelper.DataTableToModel(results);
         return(new JavaScriptSerializer().Serialize(dtModel));
     }
     catch (Exception ex)
     {
         return(ControllerHelpers.TranslateQueryException(ex.Message));
     }
 }
Пример #2
0
        public void rows_and_columns_should_be_in_the_same_order()
        {
            var dt = new DataTable();

            dt.Columns.Add("ColumnX");
            dt.Columns.Add("ColumnY");
            dt.Rows.Add(new object[] { "somestring", "anotherstring" });
            var model    = DataTableModelHelper.DataTableToModel(dt);
            var firstRow = model.Rows[0].ToArray();

            Assert.AreEqual("somestring", firstRow[0].Value);
            Assert.AreEqual("anotherstring", firstRow[1].Value);
            Assert.AreEqual("ColumnX", model.Columns[0].Name);
            Assert.AreEqual("ColumnY", model.Columns[1].Name);
        }