davidfowl / AspNetCoreDiagnosticScenarios

This repository has examples of broken patterns in ASP.NET Core applications
7.69k stars 740 forks source link

Compilation error in example with AsyncLazy #41

Closed akhlebus closed 5 years ago

akhlebus commented 5 years ago

Hi David, example with AsyncLazy doesn't compile as AsyncLazy is not awaitable.

To fix that

       var person = await _cache.GetOrAdd(id, (key) => new AsyncLazy<Person>(() => db.People.FindAsync(key)));

should be replaced with

       var person = await _cache.GetOrAdd(id, (key) => new AsyncLazy<Person>(() => db.People.FindAsync(key))).Value;
akhlebus commented 5 years ago

Oh, the issue has already been fixed in master with https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/pull/39.