Beispiel #1
0
 public override IQueryFilter GetUniqueFilter()
 {
     if (UniqueFilterProvider != null)
     {
         return(UniqueFilterProvider());
     }
     else
     {
         var colFilter = new GroupColumns();
         return(colFilter.KeyColumn == IdValue);
     }
 }
Beispiel #2
0
        public static long Count(WhereDelegate <GroupColumns> where, Database database = null)
        {
            GroupColumns c      = new GroupColumns();
            IQueryFilter filter = where (c);

            Database db    = database ?? Db.For <Group>();
            QuerySet query = GetQuerySet(db);

            query.Count <Group>();
            query.Where(filter);
            query.Execute(db);
            return(query.Results.As <CountResult>(0).Value);
        }
Beispiel #3
0
        public static Group GetOneWhere(WhereDelegate <GroupColumns> where, Database database = null)
        {
            var result = OneWhere(where, database);

            if (result == null)
            {
                GroupColumns c      = new GroupColumns();
                IQueryFilter filter = where (c);
                result = CreateFromFilter(filter, database);
            }

            return(result);
        }
Beispiel #4
0
 public static async Task BatchQuery <ColType>(int batchSize, WhereDelegate <GroupColumns> where, Action <IEnumerable <Group> > batchProcessor, Bam.Net.Data.OrderBy <GroupColumns> orderBy, Database database = null)
 {
     await Task.Run(async() =>
     {
         GroupColumns columns = new GroupColumns();
         var results          = Top(batchSize, where, orderBy, database);
         while (results.Count > 0)
         {
             await Task.Run(() =>
             {
                 batchProcessor(results);
             });
             ColType top = results.Select(d => d.Property <ColType>(orderBy.Column.ToString())).ToArray().Largest();
             results     = Top(batchSize, (GroupColumns) where (columns) && orderBy.Column > top, orderBy, database);
         }
     });
 }
Beispiel #5
0
 public static async Task BatchQuery(int batchSize, WhereDelegate <GroupColumns> where, Action <IEnumerable <Group> > batchProcessor, Database database = null)
 {
     await Task.Run(async() =>
     {
         GroupColumns columns = new GroupColumns();
         var orderBy          = Bam.Net.Data.Order.By <GroupColumns>(c => c.KeyColumn, Bam.Net.Data.SortOrder.Ascending);
         var results          = Top(batchSize, where, orderBy, database);
         while (results.Count > 0)
         {
             await Task.Run(() =>
             {
                 batchProcessor(results);
             });
             long topId = results.Select(d => d.Property <long>(columns.KeyColumn.ToString())).ToArray().Largest();
             results    = Top(batchSize, (GroupColumns) where (columns) && columns.KeyColumn > topId, orderBy, database);
         }
     });
 }
Beispiel #6
0
        public static GroupCollection Top(int count, WhereDelegate <GroupColumns> where, OrderBy <GroupColumns> orderBy, Database database = null)
        {
            GroupColumns c      = new GroupColumns();
            IQueryFilter filter = where (c);

            Database db    = database ?? Db.For <Group>();
            QuerySet query = GetQuerySet(db);

            query.Top <Group>(count);
            query.Where(filter);

            if (orderBy != null)
            {
                query.OrderBy <GroupColumns>(orderBy);
            }

            query.Execute(db);
            var results = query.Results.As <GroupCollection>(0);

            results.Database = db;
            return(results);
        }