I'm trying to generate a SQL MERGE statement from Entity Framework Core entity. To do so I need to convert all entity properties into SQL strings e.g:
bool => 1 or 0
string => 'string'
int => 123
It looks like EF Core uses class ValueConverterSelector as a factory for all different internal as well as custom value converters. I need to get it from context. How can I do it?
UPDATE: Thanks to Ivan Stoev, he proposed the following way to get converterSelector:
var converterSelector = context.GetInfrastructure().GetService<IValueConverterSelector>()
var converters = converterSelector.Select(entry.Metadata.ClrType, prop.Metadata.ClrType);
// Converters collection is empty ;(
I'm facing a new issue with it. By inspecting private fields I see that this selector has no converters registered. Hence I still can't get the right converter for each property for the entities. I need a converter selector with exact custom and built-in converters that EF is using. Any ideas?
