Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for passing in types that do not match exact entity type #124

Merged
merged 2 commits into from
Nov 20, 2023

Conversation

tsf9810292
Copy link

@tsf9810292 tsf9810292 commented Apr 6, 2022

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();
    }
}

@artiomchi artiomchi merged commit 5501125 into artiomchi:develop Nov 20, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants