public void SetConnections(List <Country> allCountries) { // If we haven't set the list of connected countries based on the IDs // from the database, we do that here if (Connections == null || CountryConnections.Count != Connections.Count) { List <ulong> ids = CountryConnections.Select(a => a.CountryOneID).Concat( CountryConnections.Select(a => a.CountryTwoID).ToList()) .Where(a => a != this.Id).ToList(); Connections = allCountries.Where(a => ids.Contains(a.Id)).ToList(); } }