Skip to content

MapValue alternative on certain fields for bools #4422

Answered by sdanyliv
Metadorius asked this question in Q&A
Discussion options

You must be logged in to vote

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 using HasConversion

builder.Entity<MainClass>()
	.Property(e => e.BoolField)
	.HasConversion((bool? b) => b == true ? 1 : 0, m => m == 1 , true);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Metadorius
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants