MapValue alternative on certain fields for bools #4422
-
The problem: I am working on legacy database with some weird storage format decisions. It may be normal to have |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It is possible. Also it can be defined for field via builder.Entity<MainClass>()
.Property(e => e.BoolField)
.HasConversion((bool? b) => b == true ? 1 : 0, m => m == 1 , true); |
Beta Was this translation helpful? Give feedback.
It is possible.
Check this test https://github.com/linq2db/linq2db/blob/master/Tests/Linq/Linq/ValueConversionTests.cs#L800,
BoolConverterNullsAttribute
has conversion code. It is a just sample.Also it can be defined for field via
MappingSchema
usingHasConversion