In a class, I have a collection of type List<CultureInfo> OfficialLanguages. I need to respect domain driven design for this project. I cannot add a backing field of type List<string> officialLanguagesCodes and handle it that way.
When I have a single property like User.Culture, I can handle a conversion like this in my OnModelCreating:
modelBuilder.Entity<User>().Property(u => u.Culture).HasConversion(c => c.Name, s => new(s));
How can I achieve something similar for a collection?
I tried the model Builder HasConversion on the collections but did not work:
modelBuilder.Entity<Community>().Property(c => c.OfficialLanguages).HasConversion(l => string.Join(',', l), s => s.Split(',', StringSplitOptions.RemoveEmptyEntries).ToList());