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

investigate if we can intercept saving changes in EF to catch changes to the model #14

Open
hahn-kev opened this issue Oct 9, 2024 · 0 comments

Comments

@hahn-kev
Copy link
Collaborator

hahn-kev commented Oct 9, 2024

This could mean that the dev provides a diff callback for each type which returns a list of changes. But otherwise using it would look just like using EF normally. Here's what this might look like

public IEnumerable<IChange> Diff(Word? oldWord, Word newWord)
{
    if (oldWord is null) return [new NewWordChange(newWord.Id, newWord.Text, newWord.Note)];
//etc...
}

public async Task CreateWord(Word word)
{
    DbContext.Set<Word>().Add(word);
    await DbContext.SaveChangesAsync();
}

we would just need to intercept the save event then call the Diff method defined by the user.

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

No branches or pull requests

1 participant