public IEnumerable <TModel> FindManyByProperty <TValue>( Expression <Func <TModel, TValue> > propertySelector, TValue value) { if (_inmemoryCollection.IsActive) { var propertyName = propertySelector.GetMemberName(); _indexes.EnsureIndex(propertyName); return(_indexes.GetByPropertyValue(propertyName, value)); } else { return(_storage.FindManyByProperty(propertySelector, value)); } }
public async Task FindByPropertyAsync <TValue>( Expression <Func <TModel, TValue> > propertySelector, TValue value, Func <TModel, Task> subscription) { IEnumerable <TModel> enumerable; if (_inmemoryCollection.IsActive) { var propertyName = propertySelector.GetMemberName(); _indexes.EnsureIndex(propertyName); enumerable = _indexes.GetByPropertyValue(propertyName, value); foreach (var item in enumerable) { await subscription(item).ConfigureAwait(false); } } else { await _storage.FindByPropertyAsync(propertySelector, value, subscription).ConfigureAwait(false); } }