0
I would like to know if it is possible to make the following conversion:
public class Pessoa
{
public bool Ativo { get; set; }
}
public class PessoaMap: IEntityTypeConfiguration<Pessoa>
{
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
{
builder.Property(x => x.Ativo)
.HasConversion(?)
// Converter o meu campo bool em char no banco de dados, por exemplo, quando for true inserir no banco de dados "S", ou inverso "N"
}
}
Tabela Pessoa
| Ativo |
|1| | 'S' |
|2| | 'N' |
Thanks, that’s what I needed, there was only one though, I can’t do it using the Valueconverter<bool, char> () class and put the expression in here, for some reason it only accepts string field instead of char, then in that case I had to do the conversion inside the same Hasconversion.
– Nicola Bogar
Cool guy! I didn’t really test the solution because I wrote by cell phone, but I’ve updated.
– Gustavo Santos