public void GroupByMetadataKeyWithMissingMetadata() { // Given List <int> groupKey = new List <int>(); Engine engine = new Engine(); CountModule count = new CountModule("A") { AdditionalOutputs = 7 }; Execute meta = new Execute((d, c) => { int groupMetadata = d.Get <int>("A") % 3; return(groupMetadata == 0 ? d : c.GetDocument(d, new MetadataItems { { "GroupMetadata", groupMetadata } })); }); GroupBy groupBy = new GroupBy("GroupMetadata", count, meta); Execute gatherData = new Execute((d, c) => { groupKey.Add(d.Get <int>(Keys.GroupKey)); return(null); }); engine.Pipelines.Add(groupBy, gatherData); // When engine.Execute(); // Then CollectionAssert.AreEquivalent(new[] { 1, 2 }, groupKey); }
public void Test3Keys() { var groupBy = GroupBy.Keys("a", "b", "c"); string expected = "{ \"a\" : 1, \"b\" : 1, \"c\" : 1 }"; Assert.AreEqual(expected, groupBy.ToJson()); }
public void TestSummarizePerColumn() { var dm = DataMap.FromDictionary(new Hashtable() { { "cat", new int[] { 1, 2, 1, 1, 3 } }, { "value1", new string[] { "a", "b", "c", "d", "e" } }, { "value2", new double[] { 10, 20, 30, 40, 50 } }, { "value3", new double[] { 1, 2, 3, 4, 5 } }, }); var g = new GroupBy(dm, new string[] { "cat" }, new string[] { "cat", "value1", "value2", "value3" }); var s = g.Summarize(new[] { "value2", "value3" }, new Dictionary <string, string>() { { "max", "Max" }, { "min", "c => c.Min()" } }); Assert.Equal(new[] { "cat", "max/value2", "min/value2", "max/value3", "min/value3" }, s.ColumnNames.ToArray()); Assert.Equal(typeof(int), s["cat"].DataType); Assert.Equal(typeof(double), s["max/value2"].DataType); Assert.Equal(typeof(double), s["min/value3"].DataType); Assert.Equal(new int[] { 1, 2, 3 }, s["cat"].ToArray <int>()); Assert.Equal(new double[] { 40, 20, 50 }, s["max/value2"].ToArray <double>()); Assert.Equal(new double[] { 1, 2, 5 }, s["min/value3"].ToArray <double>()); }
public void TestMultipleColumns2() { var dm = DataMap.FromDictionary(new OrderedDictionary() { { "cat1", new int[] { 1, 2, 1, 1, 3 } }, { "cat2", new string[] { "a", "b", "c", "a", "a" } }, { "value1", new int[] { 1, 2, 3, 4, 5 } } }); var g = new GroupBy(dm, new string[] { "cat1", "cat2" }); var groups = g.Groups().ToArray(); Assert.Equal(4, groups.Length); Assert.Equal(new[] { "cat1", "cat2", "value1" }, groups[0].ColumnNames); Assert.Equal(new[] { 1, 1 }, groups[0]["cat1"].Values); Assert.Equal(new[] { "a", "a" }, groups[0]["cat2"].Values); Assert.Equal(new[] { 1, 4 }, groups[0]["value1"].Values); Assert.Equal(new[] { "cat1", "cat2", "value1" }, groups[3].ColumnNames); Assert.Equal(new[] { 3 }, groups[3]["cat1"].Values); Assert.Equal(new[] { "a" }, groups[3]["cat2"].Values); Assert.Equal(new[] { 5 }, groups[3]["value1"].Values); }
public static List <TradeBucket> GetLastBuckets(GroupBy group, double time, int buckets) { DateTime last = DateTime.MinValue; DateTime endTime = TimeUtil.FromUnixTime((long)time); string query = string.Format(@"SELECT Time, High, Low, Volume, open, close, number_of_trades, bucket_group, ID FROM trade_buckets WHERE bucket_group = '{0}' AND TIME <= '{1}' Order By Time desc limit {2}", group.ToString(), endTime.ToString("yyyy-MM-dd HH:mm:ss"), buckets); DataTable dt = RunSELECT(query); List <TradeBucket> results = new List <TradeBucket>(); //need to reverse order for (int i = dt.Rows.Count - 1; i >= 0; i--) { TradeBucket tradeBucket = new TradeBucket(); tradeBucket.Time = (int)TimeUtil.ToUnixTime((DateTime)dt.Rows[i][0]); tradeBucket.High = (decimal)dt.Rows[i][1]; tradeBucket.Low = (decimal)dt.Rows[i][2]; tradeBucket.Volume = (decimal)dt.Rows[i][3]; tradeBucket.Open = (decimal)dt.Rows[i][4]; tradeBucket.Close = (decimal)dt.Rows[i][5]; tradeBucket.NumTrades = (int)dt.Rows[i][6]; tradeBucket.Group = GroupUtil.GetGroupBy((string)dt.Rows[i][7]); tradeBucket.Id = (int)dt.Rows[i][8]; results.Add(tradeBucket); } return(results); }
public void TestGroupBy() { var dm = DataMap.FromDictionary(new OrderedDictionary() { { "cat", new int[] { 1, 2, 1, 1, 3 } }, { "value1", new string[] { "a", "b", "c", "d", "e" } }, { "value2", new double[] { 10, 20, 30, 40, 50 } }, { "value3", new double[] { 1, 2, 3, 4, 5 } }, { "value4", new int[] { 99, 999 } } }); var g = new GroupBy(dm, new string[] { "cat" }, new string[] { "value1", "value3", "value4" }); var s1 = g.GetSubset(1); Assert.Equal(3, s1.MaxRowCount); Assert.Equal(1, s1.MinRowCount); Assert.Equal(new string[] { "value1", "value3", "value4" }, s1.ColumnNames); Assert.Equal(new string[] { "a", "c", "d" }, s1["value1"].UnderlyingList); Assert.Equal(new double[] { 1, 3, 4 }, s1["value3"].UnderlyingList); Assert.Equal(new int[] { 99 }, s1["value4"].UnderlyingList); var s2 = g.GetSubset(3); Assert.Equal(new string[] { "value1", "value3", "value4" }, s2.ColumnNames); Assert.Equal(1, s2.MaxRowCount); Assert.Equal(0, s2.MinRowCount); Assert.Equal(new string[] { "e" }, s2["value1"].UnderlyingList); Assert.Equal(new double[] { 5 }, s2["value3"].UnderlyingList); Assert.Empty(s2["value4"].UnderlyingList); }
public void SetsDocumentsInMetadata() { // Given List <IList <string> > content = new List <IList <string> >(); Engine engine = new Engine(); CountModule count = new CountModule("A") { AdditionalOutputs = 7 }; GroupBy groupBy = new GroupBy((d, c) => d.Get <int>("A") % 3, count); OrderBy orderBy = new OrderBy((d, c) => d.Get <int>(Keys.GroupKey)); Execute gatherData = new Execute((d, c) => { content.Add(d.Get <IList <IDocument> >(Keys.GroupDocuments).Select(x => x.Content).ToList()); return(null); }); engine.Pipelines.Add(groupBy, orderBy, gatherData); // When engine.Execute(); // Then Assert.AreEqual(3, content.Count); CollectionAssert.AreEquivalent(new[] { "3", "6" }, content[0]); CollectionAssert.AreEquivalent(new[] { "1", "4", "7" }, content[1]); CollectionAssert.AreEquivalent(new[] { "2", "5", "8" }, content[2]); }
public void GroupByMetadataKey() { // Given List <int> groupKey = new List <int>(); Engine engine = new Engine(); CountModule count = new CountModule("A") { AdditionalOutputs = 7 }; Core.Modules.Metadata.Meta meta = new Core.Modules.Metadata.Meta("GroupMetadata", (d, c) => d.Get <int>("A") % 3); GroupBy groupBy = new GroupBy("GroupMetadata", count, meta); Execute gatherData = new Execute((d, c) => { groupKey.Add(d.Get <int>(Keys.GroupKey)); return(null); }); engine.Pipelines.Add(groupBy, gatherData); // When engine.Execute(); // Then CollectionAssert.AreEquivalent(new[] { 0, 1, 2 }, groupKey); }
public void TestFunction() { var groupBy = GroupBy.Function("this.age >= 21"); string expected = "new BsonJavaScript(\"this.age >= 21\")"; Assert.AreEqual(expected, groupBy.ToString()); }
public Part AddGroupBy(string value, string name) { var part = new Part(value, name); GroupBy.Add(part); return(part); }
public string GetSql(bool endOfStatement = true) { var table = Reflection.GetTableName <T>(); var result = TemplateLibrary.Select; result.Append(SnippetLibrary.Table(table, TableAlias)); result.Append(SnippetLibrary.Columns(Columns.GetSql(TableAlias))); if (Join.Count > 0) { var joinTable = string.IsNullOrEmpty(TableAlias) ? table : TableAlias; result.Append(SnippetLibrary.Join(Join.GetSql(joinTable))); } if (Where.Count > 0) { result.Append(SnippetLibrary.Where(Where.GetSql(TableAlias))); } if (GroupBy.Count > 0) { result.Append(SnippetLibrary.GroupBy(GroupBy.GetSql(TableAlias))); } if (OrderBy.Count > 0) { result.Append(SnippetLibrary.OrderBy(OrderBy.GetSql(TableAlias))); } return(result.GetSql(endOfStatement)); }
public override int GetHashCode() { unchecked { var hashCode = PageSizeSet.GetHashCode(); hashCode = (hashCode * 397) ^ (Query != null ? Query.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TotalSize != null ? TotalSize.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (QueryInputs != null ? QueryInputs.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Start; hashCode = (hashCode * 397) ^ (int)AggregationOperation; hashCode = (hashCode * 397) ^ (GroupBy != null ? GroupBy.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FieldsToFetch != null ? FieldsToFetch.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SortedFields != null ? SortedFields.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Cutoff.GetHashCode(); hashCode = (hashCode * 397) ^ (CutoffEtag != null ? CutoffEtag.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DefaultField != null ? DefaultField.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (int)DefaultOperator; hashCode = (hashCode * 397) ^ SkipTransformResults.GetHashCode(); hashCode = (hashCode * 397) ^ (SkippedResults != null ? SkippedResults.GetHashCode() : 0); hashCode = (hashCode * 397) ^ DebugOptionGetIndexEntries.GetHashCode(); hashCode = (hashCode * 397) ^ (HighlightedFields != null ? HighlightedFields.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (HighlighterPreTags != null ? HighlighterPreTags.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (HighlighterPostTags != null ? HighlighterPostTags.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ResultsTransformer != null ? ResultsTransformer.GetHashCode() : 0); hashCode = (hashCode * 397) ^ DisableCaching.GetHashCode(); return(hashCode); } }
public void TestFunction() { var groupBy = GroupBy.Function("this.age >= 21"); string expected = "this.age >= 21"; Assert.AreEqual(expected, groupBy.ToString()); }
internal override IEnumerable <PropertyExpression> GetAccessedProperties() { var accessedProperties = base.GetAccessedProperties(); if (Where != null) { accessedProperties = accessedProperties.Concat(Where.GetAccessedProperties()); } if (GroupBy != null) { accessedProperties = accessedProperties.Concat(GroupBy.GetAccessedProperties()); } if (OrderBy != null) { accessedProperties = accessedProperties.Concat(OrderBy.GetAccessedProperties()); } if (Skip != null) { accessedProperties = accessedProperties.Concat(Skip.GetAccessedProperties()); } if (Limit != null) { accessedProperties = accessedProperties.Concat(Limit.GetAccessedProperties()); } return(accessedProperties); }
/// <summary> /// Default constructor /// </summary> public QueryData() { fields = new List<string>(); conditions = new List<string>(); groupBy = new GroupBy(); orderBy = new OrderBy(); }
public void Test1Key() { var groupBy = GroupBy.Keys("a"); string expected = "{ \"a\" : 1 }"; Assert.AreEqual(expected, groupBy.ToJson()); }
public void ExcludesDocumentsThatDontMatchPredicate() { // Given List <int> groupKey = new List <int>(); Engine engine = new Engine(); CountModule count = new CountModule("A") { AdditionalOutputs = 7 }; GroupBy groupBy = new GroupBy((d, c) => d.Get <int>("A") % 3, count) .Where((d, c) => d.Get <int>("A") % 3 != 0); Execute gatherData = new Execute((d, c) => { groupKey.Add(d.Get <int>(Keys.GroupKey)); return(null); }); engine.Pipelines.Add(groupBy, gatherData); // When engine.Execute(); // Then CollectionAssert.AreEquivalent(new[] { 1, 2 }, groupKey); }
public void TestObjectGroup() { Column c0 = new Column(9, 0); Column c1 = new Column(9, 1); // Illustrates the Cell's actual index = colIndex * cellsPerColumn + indexOfCellWithinCol Assert.AreEqual(7, c0.GetCell(7).GetIndex()); Assert.AreEqual(12, c1.GetCell(3).GetIndex()); Assert.AreEqual(16, c1.GetCell(7).GetIndex()); DistalDendrite dd0 = new DistalDendrite(c0.GetCell(7), 0, 0, 0); DistalDendrite dd1 = new DistalDendrite(c1.GetCell(3 /* Col 1's Cells start at 9 */), 1, 0, 1); DistalDendrite dd2 = new DistalDendrite(c1.GetCell(7 /* Col 1's Cells start at 9 */), 2, 0, 2); List <DistalDendrite> l = new List <DistalDendrite> { dd0, dd1, dd2 }; //@SuppressWarnings("unchecked") List <Tuple <DistalDendrite, Column> > expected = new List <Tuple <DistalDendrite, Column> > { new Tuple <DistalDendrite, Column>(dd0, c0), new Tuple <DistalDendrite, Column>(dd1, c1), new Tuple <DistalDendrite, Column>(dd2, c1) }; GroupBy <DistalDendrite, Column> grouper = GroupBy <DistalDendrite, Column> .Of(l, d => d.GetParentCell().GetColumn()); int i = 0; foreach (Tuple <DistalDendrite, Column> p in grouper) { Assert.AreEqual(expected[i++], p); } }
public static GroupBy GroupBy(this Where where, params string[] columnNames) { GroupBy groupby = new GroupBy(columnNames); groupby.SqlString = where.SqlString + groupby.ToString(); return(groupby); }
public IEnumerable <T> Visit <I>(GroupBy <T, I> groupBy) => InMemory .Get(groupBy.Input) .GroupBy( v => v.Item1, v => v.Item2, (key, list) => (key, list.Aggregate(groupBy.Reduce))) .SelectMany(groupBy.GetResult);
public static GroupBy ThenBy(this GroupBy groupBy, FieldRef fieldRef) { List <FieldRef> fields = groupBy.FieldRefs.ToList(); fields.Add(fieldRef); groupBy.FieldRefs = fields; return(groupBy); }
public static GroupBy GroupBy(this From from, params string[] groupNames) { GroupBy groupby = new GroupBy(groupNames); groupby.SqlString = from.SqlString + groupby.ToString(); return(groupby); }
public IActionResult UserStatisticsGroupBy([FromBody] GroupBy property) { //TODO: make more generic var groupByPredicate = property.GroupByToPredicate <Klant, string>(property); var groupByresult = this._context.Klanten.GroupBy(groupByPredicate).ToArray(); return(Ok(groupByresult)); }
public void AddGroupBy(SqlFragment f) { if (GroupBy == null) { GroupBy = new List <SqlFragment>(); } GroupBy.Add(f); }
public void Test1Key_Typed() { var groupBy = GroupBy <Test> .Keys(x => x.A); string expected = "{ \"a\" : 1 }"; Assert.AreEqual(expected, groupBy.ToJson()); }
public void Test3Keys_Typed() { var groupBy = GroupBy <Test> .Keys(x => x.A, x => x.B, x => x.C); string expected = "{ \"a\" : 1, \"b\" : 1, \"c\" : 1 }"; Assert.AreEqual(expected, groupBy.ToJson()); }
public SearchCriteria(Select select, List <Filter> filters = null, GroupBy groupBy = null, Order order = null, Pagination pagination = null) { this.Select = select; this.Filters = new Filters(filters); this.GroupBy = groupBy; this.Order = order; this.Pagination = pagination; }
/// <summary> /// Processes a Group By /// </summary> /// <param name="groupBy">Group By</param> /// <param name="context">SPARQL Evaluation Context</param> public virtual BaseMultiset ProcessGroupBy(GroupBy groupBy, SparqlEvaluationContext context) { if (context == null) { context = this.GetContext(); } return(groupBy.Evaluate(context)); }
public string Build() { var sql = new StringBuilder(); AppendSelect(sql); sql.NewLine(); AppendFrom(sql); sql.NewLine(); AppendWhere(sql); sql.NewLineIf(Where.Any()); AppendSqlPartList(sql, GroupBy, "GROUP BY"); sql.NewLineIf(GroupBy.Any()); AppendSqlPartList(sql, Having, "HAVING"); sql.NewLineIf(Having.Any()); var paging = Paging.Enabled; var pagingWithCte = paging && Paging.UseCte; if (pagingWithCte) { var sqlCte = new StringBuilder(); sqlCte.Append("WITH CTE_MAIN AS ("); sqlCte.NewLine(); sqlCte.Append(sql); sqlCte.NewLine(); sqlCte.Append(string.Format("), CTE_COUNT AS (SELECT COUNT(*) AS [{0}] FROM CTE_MAIN)", Paging.CteTotalCountFieldName)); sqlCte.NewLine(); sqlCte.Append("SELECT * FROM CTE_MAIN, CTE_COUNT"); sqlCte.NewLine(); AppendSqlPartList(sqlCte, OrderBy, "ORDER BY", removeTable: true); sqlCte.NewLine(); AppendPagination(sqlCte); sql = sqlCte; } else if (paging) { AppendSqlPartList(sql, OrderBy, "ORDER BY"); sql.NewLine(); AppendPagination(sql); sql.NewLine(); } else { AppendSqlPartList(sql, OrderBy, "ORDER BY"); } if (Separator) { sql.Append(";"); } return(Prettify(sql.ToString())); }
private GroupBy BuildGroupBy(String groupByProperty) { var groupBy = new GroupBy(); Expression propEx = null; var outModel = ViewModel; groupBy.Property = ExpressionHelpers.ParseProperty(LinqToSql, ParameterExpression, ref propEx, ref outModel, groupByProperty); groupBy.PropertyExpression = propEx; return groupBy; }
/// <summary> /// Runs the group command on this collection. /// </summary> /// <param name="query">The query (usually a QueryDocument or constructed using the Query builder).</param> /// <param name="key">The name of the field to group on.</param> /// <param name="initial">Initial value passed to the reduce function for each group.</param> /// <param name="reduce">A JavaScript function that is called for each matching document in a group.</param> /// <param name="finalize">A JavaScript function that is called at the end of the group command.</param> /// <returns>A list of results as BsonDocuments.</returns> public virtual IEnumerable <BsonDocument> Group( IMongoQuery query, string key, BsonDocument initial, BsonJavaScript reduce, BsonJavaScript finalize) { return(Group(query, GroupBy.Keys(key), initial, reduce, finalize)); }
public string[] GetGroupByFields() { if (!string.IsNullOrEmpty(GroupBy)) { var _fieldArgs = GroupBy.Split(new char[] { '-' }); return(_fieldArgs); } return(null); }
public BudgetStatsByCategoryInTimeViewModel(IEnumerable<Category> categories, IEnumerable<BudgetLine> lines, string budgetId, string budgetName, DateTime? from, DateTime? to, GroupBy grouping) { BudgetId = budgetId; BudgetName = budgetName; From = from; To = to; Categories = categories;// lines.Select(s => s.Category).Distinct().ToArray(); Grouping = grouping; TimeSerie = Group(lines, grouping); TotalLinesCount = lines.Count(); }
public string GetIsSelected(GroupBy g) { return g == Grouping ? "selected='selected'" : ""; }
/// <summary> /// Get a Join on TWO tables. /// </summary> /// <param name="tables"></param> /// <param name="c"></param> /// <param name="g"></param> /// <param name="o"></param> /// <returns></returns> public Result Join(Joinable[] tables, Condition[] c, GroupBy g, OrderBy[] o) { string sql = "SELECT "; List<string> fields = new List<string>(); foreach (Joinable j in tables) { sql += String.Join(",", j.GetFields(true)) + ", "; foreach (string item in j.GetFields(true)) { fields.Add(item); } } sql = sql.Remove(sql.Length - 2); sql += " FROM "; foreach (Joinable j in tables) { sql += j.GetTableName() + ", "; } sql = sql.Remove(sql.Length - 2); sql += " WHERE ("; sql += tables[0].GetJoinOn(tables[1]) + "=" + tables[1].GetJoinOn(tables[0]); //TODO: make this work for more tables... sql += ") "; if (c != null) { sql += " AND ("; foreach (Condition item in c) { sql += item.ToString() + " AND "; } sql = sql.Remove(sql.Length - 5); sql += ") "; } if (g != null) { sql += g.ToString(); } if (o != null) { sql += " ORDER BY "; foreach (OrderBy item in o) { sql += item.ToShortString() + ", "; } sql = sql.Remove(sql.Length - 2); } this.cmd.CommandText = sql; Result r = new Result(this.cmd.CommandText); if (this.connection.State != System.Data.ConnectionState.Open) this.connection.Open(); SQLiteDataReader re = this.cmd.ExecuteReader(); while (re.Read()) { Row row = new Row(re.StepCount); foreach (string f in fields) { row.AddCell(f, re[f].ToString()); } r.AddRow(row); } re.Close(); return r; }
public Select.Select Select(List<Expression> selectedItems, GroupBy.GroupBy groupBy, Having.Having having, OrderBy.OrderBy orderBy) { return new Select.Select(selectedItems, From, this, groupBy, having, orderBy); }
public Select.Select Select(Top top, List<Expression> selectList, GroupBy.GroupBy groupBy, OrderBy.OrderBy orderBy) { return new Select.Select(top, selectList, From, this, groupBy, orderBy); }
public Select.Select Select(Expression selectItem, GroupBy.GroupBy groupBy) { return new Select.Select(selectItem, From, this, groupBy); }
protected internal OrderBy(List<OrderByExpression> orderByExpressions, From.From from, Where.Where where, GroupBy.GroupBy groupBy) : this(orderByExpressions, from, groupBy) { Where = where; }
public Select.Select Select(Top top, Expression selectItem, Where.Where where, GroupBy.GroupBy groupBy) { return new Select.Select(top, selectItem, this, where, groupBy); }
public Select.Select Select(List<Expression> selectedItems, Where.Where where, GroupBy.GroupBy groupBy, Having.Having having) { return new Select.Select(selectedItems, this, where, groupBy, having); }
public Select.Select Select(Top top, List<Expression> selectList, Where.Where where, GroupBy.GroupBy groupBy) { return new Select.Select(top, selectList, this, where, groupBy); }
public OrderBy.OrderBy OrderBy(List<OrderBy.OrderByExpression> orderByExpressions, Where.Where where, GroupBy.GroupBy groupBy) { return new OrderBy.OrderBy(orderByExpressions, this, where, groupBy); }
protected internal OrderBy(List<OrderByExpression> orderByExpressions, From.From from, GroupBy.GroupBy groupBy) : this(orderByExpressions, from) { GroupBy = groupBy; }
public Select(Top top, List<Expression> selectList, From.From from, Where.Where where, GroupBy.GroupBy groupBy) : this(top, selectList, from, where) { GroupBy = groupBy; }
public Select(List<Expression> selectedItems, From.From from, Where.Where where, GroupBy.GroupBy groupBy, Having.Having having) : this(selectedItems, from, where, groupBy) { Having = having; }
public Select(List<Expression> selectedItems, From.From from, Where.Where where, GroupBy.GroupBy groupBy, Having.Having having, OrderBy.OrderBy orderBy) : this(selectedItems, from, where, groupBy, having) { OrderBy = orderBy; }
public Select(Top top, Expression selectItem, From.From from, Where.Where where, GroupBy.GroupBy groupBy, OrderBy.OrderBy orderBy) : this(top, selectItem, from, where, groupBy) { OrderBy = orderBy; }
private Query GroupBy(GroupBy GroupBy) { if (_ListGroupBy == null) _ListGroupBy = new GroupByList(); _ListGroupBy.Add(GroupBy); return this; }
public Select(List<Expression> selectedItems, From.From from, Where.Where where, GroupBy.GroupBy groupBy) : this(selectedItems, from, where) { GroupBy = groupBy; }
public Select.Select Select(List<Expression> selectedItems, GroupBy.GroupBy groupBy) { return new Select.Select(selectedItems, From, this, groupBy); }
public Select(Top top, Expression selectItem, From.From from, Where.Where where, GroupBy.GroupBy groupBy) : this(top, selectItem, from, where) { GroupBy = groupBy; }
public Select.Select Select(Top top, Expression selectItem, GroupBy.GroupBy groupBy, OrderBy.OrderBy orderBy) { return new Select.Select(top, selectItem, From, this, groupBy, orderBy); }
IEnumerable<TimeGroup> Group(IEnumerable<Projections.BudgetLine> lines, GroupBy grouping) { switch (grouping) { case GroupBy.Year: return lines.GroupBy(g => g.Date.Year) .Select(s => new TimeGroup(s.Key + "", s.ToCategoryStats())).ToList(); case GroupBy.Month: return lines.GroupBy(g => new { g.Date.Year, g.Date.Month }) .Select(s => new TimeGroup(CultureInfo.CurrentCulture.DateTimeFormat.MonthNames[s.Key.Month - 1] + " " + s.Key.Year, s.ToCategoryStats())).ToList(); case GroupBy.Week: return lines.GroupBy(g => new { g.Date.Year, Week = GetIso8601WeekOfYear(g.Date) }) .Select(s => new TimeGroup(s.Key.Year % 100 + " #" + s.Key.Week, s.ToCategoryStats())).ToList(); case GroupBy.Day: return lines.GroupBy(g => g.Date) .Select(s => new TimeGroup(s.Key.ToString("d"), s.ToCategoryStats())).ToList(); default: throw new NotImplementedException(); } }
public ScalarSelect(Top top, Expression selectItem, From.From from, Where.Where where, GroupBy.GroupBy groupBy, OrderBy.OrderBy orderBy) : base(null) { _select = new Select(top, selectItem, from, where, groupBy, orderBy); }
public QueryMetric AddGroupBy(GroupBy groupBy) { _groupBys.Add(groupBy); return this; }
public BetfairServerResponse<ClearedOrderSummaryReport> ListClearedOrders( BetStatus betStatus, ISet<string> eventTypeIds = null, ISet<string> eventIds = null, ISet<string> marketIds = null, ISet<RunnerId> runnerIds = null, ISet<string> betIds = null, Side? side = null, TimeRange settledDateRange = null, GroupBy? groupBy = null, bool? includeItemDescription = null, int? fromRecord = null, int? recordCount = null) { return client.ListClearedOrders( betStatus, eventTypeIds, eventIds, marketIds, runnerIds, betIds, side, settledDateRange, groupBy, includeItemDescription, fromRecord, recordCount).Result; }
private void GenerateStatementGroupBy(GroupBy.GroupBy groupBy, TextWriter writer, CodeGeneratorOptions options) { writer.Write("GROUP BY "); int i = 0; foreach (var item in groupBy.Items) { if (0 < i++) { writer.Write(", "); } GenerateCodeFromExpression(item, writer, options); } }
public Result getRow(Joinable j, string[] fields, Condition[] c = null, GroupBy g = null, OrderBy[] o = null, int limit = 0) { this.cmd.CommandText = "SELECT " + String.Join(",", fields) + " FROM " + j.GetTableName(); if (c != null) { this.cmd.CommandText += " WHERE ("; foreach (Condition item in c) { this.cmd.CommandText += item.ToString() + " AND "; } this.cmd.CommandText = this.cmd.CommandText.Remove(this.cmd.CommandText.Length - 5); this.cmd.CommandText += ") "; } if (g != null) { this.cmd.CommandText += g.ToString(); } if (o != null) { this.cmd.CommandText += " ORDER BY "; foreach (OrderBy item in o) { this.cmd.CommandText += item.ToShortString() + ", "; } this.cmd.CommandText = this.cmd.CommandText.Remove(this.cmd.CommandText.Length - 2); } if (limit != 0) { this.cmd.CommandText += " LIMIT " + limit.ToString(); } Result r = new Result(this.cmd.CommandText); if (this.connection.State != System.Data.ConnectionState.Open) this.connection.Open(); SQLiteDataReader re = this.cmd.ExecuteReader(); while (re.Read()) { Row row = new Row(re.StepCount); foreach (string f in fields) { row.AddCell(f, re[f].ToString()); } r.AddRow(row); } re.Close(); return r; }
public Select(Top top, List<Expression> selectList, From.From from, Where.Where where, GroupBy.GroupBy groupBy, OrderBy.OrderBy orderBy) : this(top, selectList, from, where, groupBy) { OrderBy = orderBy; }