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

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

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

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

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

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

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

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

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

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