public async Task FindAndModifyByPropertyAsync <TProperty>( DomainEvent e, Expression <Func <TModel, TProperty> > propertySelector, TProperty propertyValue, Func <TModel, Task> action, bool notify = false) { Func <TModel, Task> saveAction = async model => { if (!model.BuiltFromEvent(e)) { await action(model).ConfigureAwait(false); await SaveAsync(e, model, notify).ConfigureAwait(false); } }; await _storage.FindByPropertyAsync(propertySelector, propertyValue, saveAction).ConfigureAwait(false); }
#pragma warning disable S2436 // Classes and methods should not have too many generic parameters public static async Task <List <TModel> > FindByPropertyAsListAsync <TModel, TKey, TValue>( #pragma warning restore S2436 // Classes and methods should not have too many generic parameters this IMongoStorage <TModel, TKey> storage, Expression <Func <TModel, TValue> > propertySelector, TValue value) where TModel : class, IReadModelEx <TKey> { List <TModel> retValue = new List <TModel>(); Func <TModel, Task> wrapper = m => { retValue.Add(m); return(Task.CompletedTask); }; await storage.FindByPropertyAsync(propertySelector, value, wrapper).ConfigureAwait(false); return(retValue); }