using System.Collections.Generic;
using System.Threading.Tasks;
public static async Task Main()
var repo = new DataRepository();
var users = await repo.GetUsers();
var locations = await repo.GetLocations();
var results = users.Select(u => new
LocationName = locations.Single(l => l.Id == u.LocationId).Name
foreach (var result in results)
Console.WriteLine($"UserId = {result.UserId}, Location Name = {result.LocationName}");
public int Id { get; set; }
public int LocationId { get; set; }
public int Id { get; set; }
public string Name { get; set; }
public class DataRepository
public Task<List<Location>> GetLocations()
var locations = new List<Location>
new Location{Id = 1, Name = "Location 1" },
new Location{Id = 2, Name = "Location 2" },
new Location{Id = 3, Name = "Location 3" },
new Location{Id = 4, Name = "Location 4" },
new Location{Id = 5, Name = "Location 5" },
new Location{Id = 6, Name = "Location 6" },
new Location{Id = 7, Name = "Location 7" },
new Location{Id = 8, Name = "Location 8" },
new Location{Id = 9, Name = "Location 9" },
new Location{Id = 10, Name = "Location 10" },
return Task.FromResult(locations);
public Task<List<User>> GetUsers()
var users = new List<User>
new User { Id = 1, LocationId = rng.Next(1, 11) },
new User { Id = 2, LocationId = rng.Next(1, 11) },
new User { Id = 3, LocationId = rng.Next(1, 11) },
new User { Id = 4, LocationId = rng.Next(1, 11) },
new User { Id = 5, LocationId = rng.Next(1, 11) },
new User { Id = 6, LocationId = rng.Next(1, 11) },
new User { Id = 7, LocationId = rng.Next(1, 11) },
new User { Id = 8, LocationId = rng.Next(1, 11) },
new User { Id = 9, LocationId = rng.Next(1, 11) },
new User { Id = 10, LocationId = rng.Next(1, 11) },
return Task.FromResult(users);