Convert property values using type converters in BulkUpsert.

Added logic to handle type conversion using `ConvertToProvider` for properties with defined type converters. This ensures compatibility and consistency when interacting with the database in bulk upsert operations.
This commit is contained in:
Sipke Schoorstra 2025-02-18 15:36:23 +01:00
parent 74f9b06bdd
commit 10cc005848
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F

View file

@ -119,6 +119,10 @@ public static class BulkUpsertExtensions
object? value = property.IsShadowProperty()
? dbContext.Entry(entity).Property(property.Name).CurrentValue
: property.PropertyInfo?.GetValue(entity);
var converter = property.GetTypeMapping().Converter;
if (converter != null)
value = converter.ConvertToProvider(value);
values.Add(paramName);
parameters.Add(value);
@ -175,6 +179,10 @@ public static class BulkUpsertExtensions
object? value = property.IsShadowProperty()
? dbContext.Entry(entity).Property(property.Name).CurrentValue
: property.PropertyInfo?.GetValue(entity);
var converter = property.GetTypeMapping().Converter;
if (converter != null)
value = converter.ConvertToProvider(value);
placeholders.Add(paramName);
parameters.Add(value);
@ -233,6 +241,10 @@ public static class BulkUpsertExtensions
object? value = property.IsShadowProperty()
? dbContext.Entry(entity).Property(property.Name).CurrentValue
: property.PropertyInfo?.GetValue(entity);
var converter = property.GetTypeMapping().Converter;
if (converter != null)
value = converter.ConvertToProvider(value);
placeholders.Add(paramName);
parameters.Add(value);
@ -291,6 +303,10 @@ public static class BulkUpsertExtensions
object? value = property.IsShadowProperty()
? dbContext.Entry(entity).Property(property.Name).CurrentValue
: property.PropertyInfo?.GetValue(entity);
var converter = property.GetTypeMapping().Converter;
if (converter != null)
value = converter.ConvertToProvider(value);
placeholders.Add(paramName);
parameters.Add(value);
@ -353,6 +369,10 @@ public static class BulkUpsertExtensions
object? value = property.IsShadowProperty()
? dbContext.Entry(entity).Property(property.Name).CurrentValue
: property.PropertyInfo?.GetValue(entity);
var converter = property.GetTypeMapping().Converter;
if (converter != null)
value = converter.ConvertToProvider(value);
parameters.Add(value);