FlexLabs.Upsert
FlexLabs.Upsert copied to clipboard
Support for passing in types that do not match exact entity type
While the change in this PR is working great for my use case, am definitely open to other suggestions to accomplish something similar.
In general what I am trying to support is having more dynamic code that uses Upsert, allowing the ability to either passing in just object, or possibly a parent class like "MyBaseEntity". Here is some pseudo code this change allows me to run:
foreach (var syncObject in SyncObjects)
{
var enityType = Type.GetType(syncObject.FullTypeName);
foreach (var record in syncObject.Records)
{
var entity = JsonSerializer.Deserialize((JsonElement)record, enityType);
_dbContext.Upsert(entity).Run();
}
}