Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/SIL.Harmony/Changes/CreateChange.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace SIL.Harmony.Changes;

public abstract class CreateChange<T>(Guid entityId) : Change<T>(entityId) where T : class
{
public override ValueTask ApplyChange(T entity, IChangeContext context)
{
throw new NotSupportedException($"type {GetType().Name} does not support ApplyChange, because it inherits from {nameof(CreateChange<T>)}, this means it must be called with a new Guid and not one from an existing entity");
//won't be called because it's skipped by the base class for CreateChange
return default;
}
}
4 changes: 3 additions & 1 deletion src/SIL.Harmony/Changes/EditChange.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Microsoft.EntityFrameworkCore.Infrastructure;

namespace SIL.Harmony.Changes;

public abstract class EditChange<T>(Guid entityId) : Change<T>(entityId)
Expand All @@ -6,6 +8,6 @@ public abstract class EditChange<T>(Guid entityId) : Change<T>(entityId)
public override ValueTask<T> NewEntity(Commit commit, IChangeContext context)
{
throw new NotSupportedException(
$"type {GetType().Name} does not support NewEntity, because it inherits from {nameof(EditChange<T>)}, this means it must be called with a from an existing entity, not a newly generated one");
$"type {GetType().ShortDisplayName()} does not support NewEntity, because it inherits from {nameof(EditChange<T>)}, this means it must be called with an existing entity, not a newly generated one. CommitId: {commit.Id}, EntityId: {EntityId}");
}
}
Loading