Beispiel #1
0
 public static async Task BatchQuery(int batchSize, WhereDelegate <ListColumns> where, Action <IEnumerable <List> > batchProcessor, Database database = null)
 {
     await Task.Run(async() =>
     {
         ListColumns columns = new ListColumns();
         var orderBy         = Bam.Net.Data.Order.By <ListColumns>(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, (ListColumns) where (columns) && columns.KeyColumn > topId, orderBy, database);
         }
     });
 }
Beispiel #2
0
        public static ListCollection Top(int count, WhereDelegate <ListColumns> where, OrderBy <ListColumns> orderBy, Database database = null)
        {
            ListColumns  c      = new ListColumns();
            IQueryFilter filter = where (c);

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

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

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

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

            results.Database = db;
            return(results);
        }
Beispiel #3
0
        /// <summary>
        /// Gets a query filter that should uniquely identify
        /// the current instance.  The default implementation
        /// compares the Id/key field to the current instance.
        /// </summary>
        public override IQueryFilter GetUniqueFilter()
        {
            var colFilter = new ListColumns();

            return(colFilter.Id == IdValue);
        }