public async Task ReadStateAsync(string grainType, GrainReference grainReference, IGrainState grainState) { using (IServiceScope scope = _scopeFactory.CreateScope()) using (var context = scope.ServiceProvider.GetRequiredService <TContext>()) { TEntity entity = await _options.ReadStateAsync(context, grainReference) .ConfigureAwait(false); _options.SetEntity(grainState, entity); if (entity != null && _options.CheckForETag) { grainState.ETag = _options.GetETagFunc(entity); } } }
public async Task ReadStateAsync(string grainType, GrainReference grainReference, IGrainState grainState) { Expression <Func <TGrainState, bool> > expression = _options.QueryExpressionGeneratorFunc(grainReference); using (IServiceScope scope = _scopeFactory.CreateScope()) using (var context = scope.ServiceProvider.GetRequiredService <TContext>()) { TGrainState state = await _options.ReadQuery(context) .SingleOrDefaultAsync(expression) .ConfigureAwait(false); grainState.State = state; if (state != null && _options.CheckForETag) { grainState.ETag = _options.GetETagFunc(state); } } }