3
In the database I have a field ATIVO
of the kind CHAR(1)
, where 'T' = true
and 'F' = false
.
Today, in my application I am circumventing this problem with a "gambiarra", where I mapped my attribute Ativo
, as string
and created another attribute bool IsAtivo
who does something similar to this:
public bool IsAtivo
{
get { return Ativo == "T"; }
set { Ativo = value ? "T" : "F"; }
}
Nor need I comment that it is horrible that I already know, so I want to improve, when I implemented it I did not have time to look for better.
So I was wondering if you know any way to map this to the nhibernate, by mapping the Fluent-nhibernate?
// Acredito que alguma configuração aqui pode resolver meu problema
Map(t => t.Ativo, "ATIVO")
+1 Interesting. Implementation of
NHibernate.Type.CharBooleanType
.– Miguel Angelo
Thank you for the reference Miguel. :)
– Felipe Oriani
@Felipeoriani, thank you very much, for the help, very interesting that way. It worked perfectly here.
– Fernando Leal
Would it also be possible to use Enumchartype<T> in the same way? In the legacy database I have a field that is char(1) "F" or "J". Individual or Legal, and I would like to map to a boleano.
– eduardo.bbs