• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lucaslorentz / auto-compute / 11750808709

08 Nov 2024 11:01PM UTC coverage: 81.803% (+0.4%) from 81.44%
11750808709

push

github

lucaslorentz
Add initial support for computed navigations and observers

151 of 309 new or added lines in 14 files covered. (48.87%)

12 existing lines in 5 files now uncovered.

1452 of 1775 relevant lines covered (81.8%)

116.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/LLL.AutoCompute.EFCore/Metadata/Internal/ComputedObserver.cs
1
using System.Linq.Expressions;
2
using LLL.AutoCompute.EFCore.Internal;
3
using Microsoft.EntityFrameworkCore;
4
using Microsoft.EntityFrameworkCore.Metadata;
5

6
namespace LLL.AutoCompute.EFCore.Metadata.Internal;
7

8
public abstract class ComputedObserver(
9
    IEntityType entityType,
10
    LambdaExpression computedExpression)
NEW
11
    : Computed(computedExpression)
×
12
{
NEW
13
    public override IEntityType EntityType => entityType;
×
14
}
15

16
public class ComputedObserver<TEntity, TChange>(
17
    IEntityType entityType,
18
    IUnboundChangesProvider<IEFCoreComputedInput, TEntity, TChange> changesProvider,
19
    LambdaExpression computedExpression,
20
    Func<ComputedChangeEventData<TEntity, TChange>, Task> callback
NEW
21
) : ComputedObserver(entityType, computedExpression)
×
22
    where TEntity : class
23
{
24
    public override string ToDebugString()
25
    {
NEW
26
        return "Reaction";
×
27
    }
28

29
    public override IEnumerable<IEntityMember> GetDependencies()
30
    {
NEW
31
        return changesProvider.EntityContext.AllAccessedMembers;
×
32
    }
33

34
    public override async Task<int> Update(DbContext dbContext)
35
    {
NEW
36
        var numberOfUpdates = 0;
×
NEW
37
        var input = dbContext.GetComputedInput();
×
NEW
38
        var changes = await changesProvider.GetChangesAsync(input, null);
×
NEW
39
        var eventData = new ComputedChangeEventData<TEntity, TChange>
×
NEW
40
        {
×
NEW
41
            DbContext = dbContext,
×
NEW
42
            Changes = changes
×
NEW
43
        };
×
NEW
44
        await callback(eventData);
×
NEW
45
        return numberOfUpdates;
×
46
    }
47
}
48

49
public class ComputedChangeEventData<TEntity, TChange>
50
{
NEW
51
    public required DbContext DbContext { get; init; }
×
NEW
52
    public required IReadOnlyDictionary<TEntity, TChange> Changes { get; init; }
×
53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc