public void CreatePersons(int count) { var tasks = new List<Task>(); var percent = 0.0; for (var i = 0; i < count; i++) { var subPercent = Math.Round(((double)i / count) * 100); if (percent != subPercent) { percent = subPercent; Console.WriteLine(subPercent + "%"); } var t = new Person() { Id = Guid.NewGuid().ToString(), Name = StringUtils.Random(rng.Next(3, 120), this.rng), Age = rng.Next(13, 120), Gender = genders[rng.Next(0, genders.Length)], }; if (tasks.Count >= 1000) { Task.WaitAll(tasks.ToArray()); tasks.Clear(); } else { tasks.Add(this.db.Entities.PutAsync(new PutEntityRequest<Person>(t) { Batch = true, })); } } Task.WaitAll(tasks.ToArray()); tasks.Clear(); }
private IEnumerable<Person> RelationsFrom(Person person, string relationType) { return person.Relations.Where(w => w.RelationType == relationType) .Select(w => this.db.Entities.GetAsync<Person>(new GetEntityRequest(w.PersonInRelation)).Result.Content); }