public JsonResult Execute(long queryId) { var context = new DataContext(false); var dataSvc = new DataAccess(context); var queryModel = dataSvc.Get((int)ModelType.Query, queryId); ISQLObject sqlObj = _CreateQuery((QueryModel)queryModel); string sql = sqlObj.ToSQL(); var dt = _db.ExecuteQuery(sql); //byte[] data = BinarySerializer.Serialize(dt); //var output = new QueryOutput() //{ // QueryId = queryId, // Data = data, // TotalRows = dt.Rows.Count(), // ResultType = (int)QueryResultType.Success //}; //var queryOutputRepos = new EFDataRepository<Domain.QueryOutput>(context); //queryOutputRepos.AddOrUpdate(output); var vm = new TableContainerModel() { ShowFilters = false, IsEditable = false, Title = "Results" }; vm.Children = dt.Rows.Select( r => new Model() { Properties = r.Values.Select((v, i) => new ModelProperty() { Type = DataType.String, Value = v, Name = dt.Columns[i] } ).ToDictionary(p => p.Name, p => p) } ).Cast <IModel>().ToList(); vm.Properties = vm.Properties.Append( dt.Columns.Select(c => new ModelProperty() { Name = c, Type = DataType.String }) .ToDictionary(c => c.Name, c => c).ToArray() ); System.Threading.Thread.Sleep(2000); return(Json(vm, JsonRequestBehavior.AllowGet)); }
public JsonResult ToSQL(long queryId) { var context = new DataContext(false); var dataSvc = new DataAccess(context); var queryModel = dataSvc.Get((int)ModelType.Query, queryId); ISQLObject sqlObj = _CreateQuery((QueryModel)queryModel); string sql = sqlObj.ToSQL(); return(Json(sql, JsonRequestBehavior.AllowGet)); }