Allow specifying value converter instance in ConfigureConventions
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
In `ConfigureConventions` I can specify a converter for all properties of certain type. But unlike with "regular" converter configuring, here I can only specify converter _type_, but not _instance_:
``` csharp
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
configurationBuilder
.Properties()
.HaveConversion();
}
```
This limits only to converters which have parameterless constructors. But in some cases it's useful to be able to pass some additional information to particular converter usage.
For instance, I have a converter which converts a `DateTimeOffset` to `DateTime` in specified time zone. Converter's constructor has this look:
`public DateTimeOffsetToDateTimeConverter(TimeZoneInfo timeZone)`
To configure properties with this converter with a specific time zone I have to derive new type which hardcodes this time zone, so it has parameterless contructor and specifying just type is enough. But even this trick will not work if you need to decide on parameter value at run time.
Contributor guide
Assessment
This issue has not been assessed yet.