sillsdev / sillsdev/harmony

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

Open
#14 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
14
Forks
4
Avg merge
3d 21h
Merged PRs (30d)
3

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the linked EF Core save-changes interception documentation and the DbContext/SaveChangesAsync flow shown in the issue. Determine whether a user-supplied per-type Diff callback can be invoked for added, modified, and deleted entities while preserving normal EF usage; no repository files or tests are named, so done means a documented feasibility decision and scoped follow-up.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.