Skip to content

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

@hahn-kev

Description

@hahn-kev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions