Ejemplo n.º 1
0
        public ActionResult SelectRecordsCount(Param[] _params)
        {
            var qb = QueryBuilderStore.Get(instanceId);
            var qt = QueryTransformerStore.Get(instanceId);
            var qtForSelectRecordsCount = QueryTransformerStore.Create(instanceId + "_for_records_count");

            qtForSelectRecordsCount.QueryProvider = qb.SQLQuery;
            qtForSelectRecordsCount.Assign(qt);
            qtForSelectRecordsCount.Skip("");
            qtForSelectRecordsCount.Take("");
            qtForSelectRecordsCount.SelectRecordsCount("recCount");

            try
            {
                var data = Execute(qtForSelectRecordsCount, _params);
                return(Json(data.First().Values.First(), JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(new ErrorOutput {
                    Error = e.Message
                }, JsonRequestBehavior.AllowGet));
            }
            finally
            {
                QueryTransformerStore.Remove(instanceId + "_for_records_count");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates and initializes a new instance of the QueryTransformer object.
        /// </summary>
        /// <param name="query">SQL Query to transform.</param>
        /// <returns>Returns instance of the QueryTransformer object.</returns>
        private QueryTransformer CreateQueryTransformer(SQLQuery query)
        {
            var qt = QueryTransformerStore.Create(instanceId);

            qt.QueryProvider = query;
            qt.AlwaysExpandColumnsInQuery = true;

            return(qt);
        }
        private void UpdateRecordCount(QueryTransformer qt)
        {
            var qtForSelectRecordsCount = QueryTransformerStore.Create("QueryResults_for_select_records_count");

            qtForSelectRecordsCount.QueryProvider = qt.QueryProvider;
            qtForSelectRecordsCount.Assign(qt);
            qtForSelectRecordsCount.Skip("");
            qtForSelectRecordsCount.Take("");
            qtForSelectRecordsCount.SelectRecordsCount("recCount");

            try
            {
                var data = SelectRecordsCount.GetData(qtForSelectRecordsCount, new Param[0]);
                _recordsCount     = int.Parse(data.First().Values.First().ToString());
                recordsCount.Text = "Records count: " + _recordsCount;
            }
            finally
            {
                QueryTransformerStore.Remove("QueryResults_for_select_records_count");
            }
        }
Ejemplo n.º 4
0
        public override object GetDataForModel(Param[] _params)
        {
            var qb = QueryBuilderStore.Get("QueryResults");
            var qt = QueryTransformerStore.Get("QueryResults");
            var qtForSelectRecordsCount = QueryTransformerStore.Create("QueryResults_for_select_records_count");

            qtForSelectRecordsCount.QueryProvider = qb.SQLQuery;
            qtForSelectRecordsCount.Assign(qt);
            qtForSelectRecordsCount.Skip("");
            qtForSelectRecordsCount.Take("");
            qtForSelectRecordsCount.SelectRecordsCount("recCount");

            try
            {
                var data = GetData(qtForSelectRecordsCount, _params);
                return(data.First().Values.First());
            }
            finally
            {
                QueryTransformerStore.Remove("QueryResults_for_select_records_count");
            }
        }