I have an object with an array property that I want to persist in the database as a delimited string. How to I Map that property to the field in the database and vice versus?
public class User() {
public int Id { get; set; }
public string[] Roles { get; set; }
}
Incomplete Config Class:
public class UserConfig : EntityTypeConfiguration<User> {
public UserConfig() {
this.Property(u => u.Roles).__???__
this.Map(u => u.Properties<string[]>(r => r.Roles).__???__))
.HasColumnName("roles");
}
}
For this example the "Roles" property would be converted to "roleA,roleB,roleC" when going to the database and then transformed back to an array when read from the database. Is there an on data mapping event somewhere?