private void Query() { string[] s = textBox1.Text.Split(','); try { DateTime dt = FastDateTime.Now; var q = rap.Query(s[0].Trim(), s[1].Trim()); toolStripStatusLabel2.Text = "Query time (sec) = " + FastDateTime.Now.Subtract(dt).TotalSeconds; dataGridView1.DataSource = q.Rows; toolStripStatusLabel1.Text = "Count = " + q.Count.ToString("#,0"); stsError.Text = ""; } catch (Exception ex) { stsError.Text = ex.Message; dataGridView1.DataSource = null; toolStripStatusLabel1.Text = "Count = 0"; toolStripStatusLabel2.Text = "Query time (sec) = 0"; } }
private void Query() { int c = textBox1.Text.IndexOf(','); string viewname = textBox1.Text.Substring(0, c); string args = textBox1.Text.Substring(c + 1); try { DateTime dt = FastDateTime.Now; var q = rap.Query(viewname, args.Trim()); toolStripStatusLabel2.Text = "Query time (sec) = " + FastDateTime.Now.Subtract(dt).TotalSeconds; dataGridView1.DataSource = q.Rows; toolStripStatusLabel1.Text = "Count = " + q.Count.ToString("#,0"); stsError.Text = ""; } catch (Exception ex) { stsError.Text = ex.Message; dataGridView1.DataSource = null; toolStripStatusLabel1.Text = "Count = 0"; toolStripStatusLabel2.Text = "Query time (sec) = 0"; } }
public static List <object> Sum_Products_based_on_filter(IRaptorDB rap, string filter) { var q = rap.Query <SalesItemRowsViewRowSchema>(filter); var res = from x in q.Rows group x by x.Product into g select new sumtype // avoid anonymous types { Product = g.Key, TotalPrice = g.Sum(p => p.Price), TotalQTY = g.Sum(p => p.QTY) }; return(res.ToList <object>()); }
public static List<object> Sum_Products_based_on_filter(IRaptorDB rap, string filter) { var q = rap.Query<SalesItemRowsViewRowSchema>(filter); var res = from x in q.Rows group x by x.Product into g select new sumtype // avoid anonymous types { Product = g.Key, TotalPrice = g.Sum(p => p.Price), TotalQTY = g.Sum(p => p.QTY) }; return res.ToList<object>(); }
private Result <object> DoQuery(IRaptorDB rdb, HttpListenerContext ctx, string path, RDBRoute route) { string qry = ctx.Request.Url.GetComponents(UriComponents.Query, UriFormat.Unescaped); string viewname = path; if (route != null) { //if (route.EntityType != null) //{ // if (qry != "") // { // // fetch the json document // string[] s = qry.Split('='); // object obj = null; // if (_jsonstore.GetObject(Guid.Parse(s[1].Replace("\"", "")), out obj)) // { // RDBJsonContainer d = (RDBJsonContainer)obj; // WriteResponse(ctx, 200, d.json); // return; // } // } // WriteResponse(ctx, 404, "GUID not found :" + qry); // return; //} if (route.Viewname == null && route.function != null) { viewname = route.Viewname; var o = route.function(_rdb, qry); Result <object> resf = new Result <object>(true); resf.Rows = o; resf.TotalCount = o.Count; resf.Count = o.Count; resf.Title = route.Viewname; return(resf); } } // parse "start" and "count" from qry if exists int start = 0; int count = -1; string orderby = ""; var m = _start_regex.Match(qry); if (m.Success) { start = int.Parse(m.Groups["start"].Value); qry = qry.Replace(m.Value, ""); } m = _count_regex.Match(qry); if (m.Success) { count = int.Parse(m.Groups["count"].Value); qry = qry.Replace(m.Value, ""); } m = _order_regex.Match(qry); if (m.Success) { orderby = m.Groups["orderby"].Value; qry = qry.Replace(m.Value, ""); } var res = rdb.Query(viewname, qry, start, count, orderby); res.Title = viewname; return(res); }