public override IQueryFilter GetUniqueFilter() { if (UniqueFilterProvider != null) { return(UniqueFilterProvider()); } else { var colFilter = new TestTableColumns(); return(colFilter.KeyColumn == IdValue); } }
public static long Count(WhereDelegate <TestTableColumns> where, Database database = null) { TestTableColumns c = new TestTableColumns(); IQueryFilter filter = where (c); Database db = database ?? Db.For <TestTable>(); QuerySet query = GetQuerySet(db); query.Count <TestTable>(); query.Where(filter); query.Execute(db); return(query.Results.As <CountResult>(0).Value); }
public static TestTable GetOneWhere(WhereDelegate <TestTableColumns> where, Database database = null) { var result = OneWhere(where, database); if (result == null) { TestTableColumns c = new TestTableColumns(); IQueryFilter filter = where (c); result = CreateFromFilter(filter, database); } return(result); }
public static async Task BatchQuery <ColType>(int batchSize, WhereDelegate <TestTableColumns> where, Action <IEnumerable <TestTable> > batchProcessor, Bam.Net.Data.OrderBy <TestTableColumns> orderBy, Database database = null) { await System.Threading.Tasks.Task.Run(async() => { TestTableColumns columns = new TestTableColumns(); 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, (TestTableColumns) where (columns) && orderBy.Column > top, orderBy, database); } }); }
public static async Task BatchQuery(int batchSize, WhereDelegate <TestTableColumns> where, Action <IEnumerable <TestTable> > batchProcessor, Database database = null) { await Task.Run(async() => { TestTableColumns columns = new TestTableColumns(); var orderBy = Bam.Net.Data.Order.By <TestTableColumns>(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, (TestTableColumns) where (columns) && columns.KeyColumn > topId, orderBy, database); } }); }
public static TestTableCollection Top(int count, WhereDelegate <TestTableColumns> where, OrderBy <TestTableColumns> orderBy, Database database = null) { TestTableColumns c = new TestTableColumns(); IQueryFilter filter = where (c); Database db = database ?? Db.For <TestTable>(); QuerySet query = GetQuerySet(db); query.Top <TestTable>(count); query.Where(filter); if (orderBy != null) { query.OrderBy <TestTableColumns>(orderBy); } query.Execute(db); var results = query.Results.As <TestTableCollection>(0); results.Database = db; return(results); }