public record Currency
{
public string Code {get; init;}
public HashSet<Country> Countries {get; init;}
}
public record Country
{
public string Code {get; init;}
public HashSet<Currency> Currencies {get; init;}
}
Assuming that:
A country accepts one to many currencies.
A currency is used in one to many countries.
After some research, records seem to be a reasonable choice for storing countries and currencies, because once they are loaded from the database, I do not need to change them anymore.
However, I do not know how I can construct a hashset of currency records and a hashset of country records, containing the complete information of each other.
In the database I do have a CurrencyCountryRelationship pivot table.
With that table, I can create a list of currency, and then a list of country, and then construct a list of relationship to achieve the result, but I do not want to use them for object models, if possible.
//I just want to cache a one-off configuration from the database for later usage. So if records are not the right choice please let me know. Any solutions will be great. Thanks!