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