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

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

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

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

            return(result);
        }
예제 #4
0
 public static async Task BatchQuery(int batchSize, WhereDelegate <ListItemColumns> where, Action <IEnumerable <ListItem> > batchProcessor, Database database = null)
 {
     await Task.Run(async() =>
     {
         ListItemColumns columns = new ListItemColumns();
         var orderBy             = Bam.Net.Data.Order.By <ListItemColumns>(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, (ListItemColumns) where (columns) && columns.KeyColumn > topId, orderBy, database);
         }
     });
 }
예제 #5
0
        public static ListItemCollection Top(int count, WhereDelegate <ListItemColumns> where, OrderBy <ListItemColumns> orderBy, Database database = null)
        {
            ListItemColumns c      = new ListItemColumns();
            IQueryFilter    filter = where (c);

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

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

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

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

            results.Database = db;
            return(results);
        }
예제 #6
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 ListItemColumns();

            return(colFilter.Id == IdValue);
        }