// history public Task <List <HistoryItem> > GetHistoryAsync(string typeFilter = null, string actionFilter = null, string reminderFilter = null, byte responceFilter = 3) { AsyncTableQuery <HistoryItem> query = _database.Table <HistoryItem>(); if (typeFilter != null) { query = query.Where(h => h.TrackedType.Equals(typeFilter)); } if (actionFilter != null) { query = query.Where(h => h.Action.Equals(actionFilter)); } if (reminderFilter != null) { query = query.Where(h => h.Reminder.Equals(reminderFilter)); } if (responceFilter != 3) { query = query.Where(h => h.Responce == responceFilter); } return(query.OrderByDescending(h => h.ID).ToListAsync()); }
protected override AsyncTableQuery <Wallet> ApplyFilters(AsyncTableQuery <Wallet> query, WalletFilter filter) { if (!string.IsNullOrEmpty(filter.Name)) { query = query.Where(x => x.Name.Contains(filter.Name)); } if (filter.ImageId.HasValue) { query = query.Where(x => x.ImageId == filter.ImageId.Value); } return(base.ApplyFilters(query, filter)); }
protected override AsyncTableQuery <Transaction> ApplyFilters(AsyncTableQuery <Transaction> query, TransactionFilter filter) { if (filter.DateSince.HasValue) { query = query.Where(x => x.Date >= filter.DateSince.Value); } if (filter.IsCashPayment) { query = query.Where(x => x.BankId == null); } return(base.ApplyFilters(query, filter)); }
public async Task <T> Select(Guid identifier) { AsyncTableQuery <T> tb = database.Table <T>(); var item = tb.Where(x => x.Id == identifier); return(await item.FirstAsync()); }
private async Task <int> CountReady(Expression <Func <T, bool> > filter = null, bool includeDeleted = false) { AsyncTableQuery <T> tableQuery = _mainContext.GetCurrentContext().Table <T>(); if (!includeDeleted) { tableQuery = tableQuery.Where(q => q.IsDeleted.Equals(includeDeleted)); } if (filter != null) { tableQuery = tableQuery.Where(filter); } return(await tableQuery.CountAsync()); }
public static async Task <bool> ExistWithNameAsync(this AsyncTableQuery <ProjectData> query, string projectName, Guid clientId) { List <ProjectData> existingProjects; if (clientId != Guid.Empty) { existingProjects = await query .Where(r => r.Name == projectName && r.ClientId == clientId) .ToListAsync().ConfigureAwait(false); } else { existingProjects = await query .Where(r => r.Name == projectName && r.ClientId == null) .ToListAsync().ConfigureAwait(false); } return(existingProjects.Count != 0); }
protected override AsyncTableQuery <Currency> ApplyFilters(AsyncTableQuery <Currency> query, CurrencyFilter filter) { if (!string.IsNullOrEmpty(filter.Code)) { query = query.Where(x => x.Code.Contains(filter.Code)); } return(base.ApplyFilters(query, filter)); }
protected override AsyncTableQuery <WalletCategory> ApplyFilters(AsyncTableQuery <WalletCategory> query, WalletCategoryFilter filter) { if (filter.WalletId.HasValue && filter.CategoryId.HasValue) { query = query.Where(x => x.WalletId.Equals(filter.WalletId) && x.CategoryId.Equals(filter.CategoryId)); } else if (filter.WalletId.HasValue) { query = query.Where(x => x.WalletId.Equals(filter.WalletId)); } else if (filter.CategoryId.HasValue) { query = query.Where(x => x.CategoryId.Equals(filter.CategoryId)); } return(base.ApplyFilters(query, filter)); }
protected override AsyncTableQuery <Rule> ApplyFilters(AsyncTableQuery <Rule> query, RuleFilter filter) { if (!string.IsNullOrEmpty(filter.Name)) { query = query.Where(x => x.Name.Contains(filter.Name)); } if (!string.IsNullOrEmpty(filter.Pattern)) { query = query.Where(x => x.Pattern.Contains(filter.Pattern)); } if (filter.CategoryId.HasValue) { query = query.Where(x => x.CategoryId == filter.CategoryId.Value); } return(base.ApplyFilters(query, filter)); }
public async Task <IEnumerable <Mushroom> > GetMushroomsAsync(IEnumerable <int> ids) { AsyncTableQuery <Mushroom> result = _database.Table <Mushroom>(); if (ids != null && ids.Any()) { result = result.Where(m => ids.Contains(m.Id)); } return(await result.ToListAsync()); }
private async Task <IList <T> > GetManyReady(Expression <Func <T, bool> > filter = null, Func <AsyncTableQuery <T>, AsyncTableQuery <T> > order = null, int skip = 0, int take = 0, bool includeDeleted = false) { AsyncTableQuery <T> tableQuery = _mainContext.GetCurrentContext().Table <T>(); if (!includeDeleted) { tableQuery = tableQuery.Where(q => q.IsDeleted.Equals(includeDeleted)); } if (filter != null) { tableQuery = tableQuery.Where(filter); } if (order != null) { tableQuery = order(tableQuery); } if (order == null) { tableQuery = tableQuery.OrderByDescending(b => b.CreatedDate); } if (skip > 0) { tableQuery = tableQuery.Skip(skip); } if (take > 0) { tableQuery = tableQuery.Take(take); } return(await tableQuery.ToListAsync()); }
public async Task <List <T> > Get <TValue>(Expression <Func <T, bool> > predicate = null, Expression <Func <T, TValue> > orderBy = null) { AsyncTableQuery <T> query = db.Table <T>(); if (predicate != null) { query = query.Where(predicate); } if (orderBy != null) { query = query.OrderBy <TValue>(orderBy); } return(await query.ToListAsync()); }
protected virtual AsyncTableQuery <T1> ApplyFilters(AsyncTableQuery <T1> query, T2 filter) { if (filter.Ids != null && filter.Ids.Any()) { query = query.Where(x => filter.Ids.Contains(x.Id)); } if (filter.Skip > 0) { query = query.Skip(filter.Skip.Value); } if (filter.Take > 0) { query = query.Take(filter.Take.Value); } return(query); }
public async Task <List <TEntity> > Find(Expression <Func <TEntity, bool> > predicate) => await _entities.Where(predicate).ToListAsync();
/// <inheritdoc cref="QueryableExtensions.WhereOr{T}(IReadOnlyList{Expression{Func{T, bool}}})"/> public static AsyncTableQuery <T> WhereOr <T>(this AsyncTableQuery <T> source, IReadOnlyList <Expression <Func <T, bool> > > predicates) where T : new() { var predicate = ExpressionHelper.WhereOr(predicates); return(source.Where(predicate)); }
public static async Task <bool> ExistWithNameAsync(this AsyncTableQuery <ClientData> query, string name) { var rows = await query.Where(r => r.Name == name).ToListAsync().ConfigureAwait(false); return(rows.Count != 0); }
public static bool Any(this AsyncTableQuery <User> table, Expression <Func <User, bool> > predExpr) => table.Where(predExpr).Any();