private static IEnumerableAsync <LookupByIdModel> CreateLookups(int totalResources, int totalLookups) { var rand = new Random(); var lookups = Enumerable .Range(0, totalLookups) .Select(index => Guid.NewGuid()) .ToArray(); return(Enumerable .Range(0, totalResources) .Select( index => { return Task.Run <LookupByIdModel>( () => { var idValue = GetIdValue(); Thread.Sleep(0); // (int)(rand.NextDouble() * 100)); return LookupByIdModel.GetModel(idValue); }); }) .AsyncEnumerable()); Guid GetIdValue() { var index = rand.Next(0, totalLookups); return(lookups[index]); } }
private static async Task <LookupByIdModel> CreateLookupById(Guid idValue) { var idLookup = LookupByIdModel.GetModel(idValue); var entityFromDb = await idLookup.StorageCreateAsync( (discard) => discard.Entity); return(entityFromDb); }