示例#1
0
 public static MaxGroupAggregateQuery <TKey, TRecord, TExpressionValue> Max <TKey, TRecord, TExpressionValue>(
     this IGroupingQuery <TKey, TRecord[]> groupingQuery,
     Expression <Func <TRecord, TExpressionValue> > field = null
     )
 {
     return(new MaxGroupAggregateQuery <TKey, TRecord, TExpressionValue>(groupingQuery, field));
 }
示例#2
0
 public static AvgGroupAggregateQuery <TKey, TRecord, TAvgType> Avg <TKey, TRecord, TAvgType>(
     this IGroupingQuery <TKey, TRecord[]> groupingQuery,
     Expression <Func <TRecord, TAvgType> > field = null
     )
 {
     return(new AvgGroupAggregateQuery <TKey, TRecord, TAvgType>(groupingQuery, field));
 }
示例#3
0
 public static SumGroupAggregateQuery <TKey, TRecord, TSumType> Sum <TKey, TRecord, TSumType>(
     this IGroupingQuery <TKey, TRecord[]> groupingQuery,
     Expression <Func <TRecord, TSumType> > field = null
     )
 {
     return(new SumGroupAggregateQuery <TKey, TRecord, TSumType>(groupingQuery, field));
 }
示例#4
0
 public static ContainsGroupAggregateQuery <TKey, TRecord> Contains <TKey, TRecord>(
     this IGroupingQuery <TKey, TRecord[]> groupingQuery,
     Expression <Func <TRecord, bool> > predicate = null
     )
 {
     return(new ContainsGroupAggregateQuery <TKey, TRecord>(groupingQuery, predicate));
 }
示例#5
0
        public static void GroupQuery()
        {
            IQuery <User> q = context.Query <User>();

            IGroupingQuery <User> g = q.Where(a => a.Id > 0).GroupBy(a => a.Age);

            g = g.Having(a => a.Age > 1 && Sql.Count() > 0);

            g.Select(a => new { a.Age, Count = Sql.Count(), Sum = Sql.Sum(a.Age), Max = Sql.Max(a.Age), Min = Sql.Min(a.Age), Avg = Sql.Average(a.Age) }).ToList();

            /*
             *
             */

            ConsoleHelper.WriteLineAndReadKey();
        }
示例#6
0
        public virtual void GroupQuery()
        {
            IQuery <Person> q = this.DbContext.Query <Person>();

            IGroupingQuery <Person> g = q.Where(a => a.Id > 0).GroupBy(a => a.Age);

            g = g.Having(a => true);

            g.Select(a => new { a.Age, Count = Sql.Count(), Sum = Sql.Sum(a.Age), Max = Sql.Max(a.Age), Min = Sql.Min(a.Age), Avg = Sql.Average(a.Age) }).ToList();

            /*
             * SELECT [Person].[Age] AS [Age],COUNT(1) AS [Count],CAST(SUM([Person].[Age]) AS INTEGER) AS [Sum],CAST(MAX([Person].[Age]) AS INTEGER) AS [Max],CAST(MIN([Person].[Age]) AS INTEGER) AS [Min],CAST(AVG([Person].[Age]) AS REAL) AS [Avg] FROM [Person] AS [Person] WHERE [Person].[Id] > 0 GROUP BY [Person].[Age] HAVING ([Person].[Age] > 1 AND COUNT(1) > 0)
             */

            ConsoleHelper.WriteLineAndReadKey();
        }
示例#7
0
        public static void GroupQuery()
        {
            IQuery <User> q = context.Query <User>();

            IGroupingQuery <User> g = q.Where(a => a.Id > 0).GroupBy(a => a.Age);

            g = g.Having(a => a.Age > 1 && AggregateFunctions.Count() > 0);

            g.Select(a => new { a.Age, Count = AggregateFunctions.Count(), Sum = AggregateFunctions.Sum(a.Age), Max = AggregateFunctions.Max(a.Age), Min = AggregateFunctions.Min(a.Age), Avg = AggregateFunctions.Average(a.Age) }).ToList();

            /*
             * SELECT [Users].[Age] AS [Age],COUNT(1) AS [Count],CAST(SUM([Users].[Age]) AS INT) AS [Sum],MAX([Users].[Age]) AS [Max],MIN([Users].[Age]) AS [Min],CAST(AVG([Users].[Age]) AS FLOAT) AS [Avg] FROM [Users] AS [Users] WHERE [Users].[Id] > 0 GROUP BY [Users].[Age] HAVING ([Users].[Age] > 1 AND COUNT(1) > 0)
             */

            ConsoleHelper.WriteLineAndReadKey();
        }
示例#8
0
        public static void GroupQuery()
        {
            IQuery <User> q = context.Query <User>();

            IGroupingQuery <User> g = q.Where(a => a.Id > 0).GroupBy(a => a.Age);

            g = g.Having(a => a.Age > 1 && AggregateFunctions.Count() > 0);

            g.Select(a => new { a.Age, Count = AggregateFunctions.Count(), Sum = AggregateFunctions.Sum(a.Age), Max = AggregateFunctions.Max(a.Age), Min = AggregateFunctions.Min(a.Age), Avg = AggregateFunctions.Average(a.Age) }).ToList();

            /*
             * SELECT "USERS"."AGE" AS "AGE",COUNT(1) AS "COUNT",SUM("USERS"."AGE") AS "SUM",MAX("USERS"."AGE") AS "MAX",MIN("USERS"."AGE") AS "MIN",AVG("USERS"."AGE") AS "AVG" FROM "USERS" "USERS" WHERE "USERS"."ID" > 0 GROUP BY "USERS"."AGE" HAVING ("USERS"."AGE" > 1 AND COUNT(1) > 0)
             */

            ConsoleHelper.WriteLineAndReadKey();
        }
示例#9
0
        public static void GQTest()
        {
            MsSqlContext context = new MsSqlContext(DbHelper.ConnectionString);

            IQuery <User> q = context.Query <User>();

            IGroupingQuery <User> g = q.Where(a => a.Id > 0).GroupBy(a => a.Age);

            g = g.Having(a => a.Age > 1 && Sql.Count() > 0);

            g.Select(a => new { a.Age, Count = Sql.Count(), Sum = Sql.Sum(a.Age), Max = Sql.Max(a.Age), Min = Sql.Min(a.Age), Avg = Sql.Average(a.Age) }).ToList();

            /*
             * SELECT [Users].[Age] AS [Age],COUNT(1) AS [Count],SUM([Users].[Age]) AS [Sum],MAX([Users].[Age]) AS [Max],MIN([Users].[Age]) AS [Min],CAST(AVG([Users].[Age]) AS FLOAT) AS [Avg] FROM [Users] AS [Users] WHERE [Users].[Id] > 0 GROUP BY [Users].[Age] HAVING ([Users].[Age] > 1 AND COUNT(1) > 0)
             */
        }
示例#10
0
        public static void GroupQuery()
        {
            IQuery <User> q = context.Query <User>();

            IGroupingQuery <User> g = q.Where(a => a.Id > 0).GroupBy(a => a.Age);

            g = g.Having(a => a.Age > 1 && AggregateFunctions.Count() > 0);

            g.Select(a => new { a.Age, Count = AggregateFunctions.Count(), Sum = AggregateFunctions.Sum(a.Age), Max = AggregateFunctions.Max(a.Age), Min = AggregateFunctions.Min(a.Age), Avg = AggregateFunctions.Average(a.Age) }).ToList();

            /*
             * SELECT `Users`.`Age` AS `Age`,COUNT(1) AS `Count`,CAST(SUM(`Users`.`Age`) AS SIGNED) AS `Sum`,MAX(`Users`.`Age`) AS `Max`,MIN(`Users`.`Age`) AS `Min`,AVG(`Users`.`Age`) AS `Avg` FROM `Users` AS `Users` WHERE `Users`.`Id` > 0 GROUP BY `Users`.`Age` HAVING (`Users`.`Age` > 1 AND COUNT(1) > 0)
             */

            ConsoleHelper.WriteLineAndReadKey();
        }
示例#11
0
 public CountGroupAggregateQuery(IGroupingQuery <TKey, TRecord[]> groupingQuery, Expression <Func <TRecord, bool> > predicate)
 {
     this.groupingQuery = groupingQuery;
     this.predicate     = predicate;
 }
示例#12
0
 public MapGroupQuery(IGroupingQuery <TKey, TOriginal[]> groupingQuery, Expression <Func <TOriginal, TTarget> > mapExpression)
 {
     this.groupingQuery = groupingQuery;
     this.mapExpression = mapExpression;
 }
 public MinGroupAggregateQuery(IGroupingQuery <TKey, TRecord[]> groupingQuery, Expression <Func <TRecord, TExpressionValue> > field)
 {
     this.groupingQuery = groupingQuery;
     this.field         = field;
 }
示例#14
0
 public ReduceGroupQuery(IGroupingQuery <TKey, TRecord[]> groupingQuery, Expression <Func <TRecord, TRecord, TRecord> > reduceFunction)
 {
     this.groupingQuery  = groupingQuery;
     this.reduceFunction = reduceFunction;
 }
示例#15
0
 public static ReduceGroupQuery <TKey, TRecord> Reduce <TKey, TRecord>(
     this IGroupingQuery <TKey, TRecord[]> groupingQuery,
     Expression <Func <TRecord, TRecord, TRecord> > reduceFunction)
 {
     return(new ReduceGroupQuery <TKey, TRecord>(groupingQuery, reduceFunction));
 }
示例#16
0
 public static MapGroupQuery <TKey, TOriginal, TTarget> Map <TKey, TOriginal, TTarget>(
     this IGroupingQuery <TKey, TOriginal[]> groupingQuery,
     Expression <Func <TOriginal, TTarget> > mapExpression)
 {
     return(new MapGroupQuery <TKey, TOriginal, TTarget>(groupingQuery, mapExpression));
 }
示例#17
0
 public static UngroupQuery <TKey, TValue, TResult> Ungroup <TKey, TValue, TResult>(this IGroupingQuery <TKey, TValue> groupingQuery)
 {
     return(new UngroupQuery <TKey, TValue, TResult>(groupingQuery));
 }
示例#18
0
 public static UngroupQuery <TKey, TValue, UngroupObject <TKey, TValue> > Ungroup <TKey, TValue>(this IGroupingQuery <TKey, TValue> groupingQuery)
 {
     return(new UngroupQuery <TKey, TValue, UngroupObject <TKey, TValue> >(groupingQuery));
 }
示例#19
0
 public SumGroupAggregateQuery(IGroupingQuery <TKey, TRecord[]> groupingQuery, Expression <Func <TRecord, TSumType> > field)
 {
     this.groupingQuery = groupingQuery;
     this.field         = field;
 }
示例#20
0
 public UngroupQuery(IGroupingQuery <TKey, TValue> groupingQuery)
 {
     this.groupingQuery = groupingQuery;
 }