I'm currently trying to discover the idea behind aggregate roots and their relation to repositories.
Given are the following domain entities:
public class Country {
public string Name { get; set; }
public ICollection<City> Cities { get; set; }
}
public class City {
public string Name { get; set; }
}
I guess I correctly identified Country as an aggregate root for City since in my domain, there shouldn't be any cities that are not located within a country. It should be only possible to add a new city to the data storage via a country and if a country get's deleted, every city inside should be removed too.
Now, how does such a Country Repository might look like? And how does the Country Aggregate Root look like? Is there a CityRepository inside the domain (which would allow me to add a city to the database even if there is no related country!)? And is there a CountryRepository inside the Country (somehow the country needs to populate it's cities? Or is this the job of a repository?)