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

lucaslorentz / auto-compute / 11755569045

09 Nov 2024 10:37AM UTC coverage: 80.033% (-1.7%) from 81.696%
11755569045

push

github

lucaslorentz
Add initial support for computed navigations and observers

159 of 357 new or added lines in 22 files covered. (44.54%)

41 existing lines in 6 files now uncovered.

1459 of 1823 relevant lines covered (80.03%)

113.72 hits per line

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

40.0
/src/LLL.AutoCompute.EFCore/Extensions/PropertyBuilderExtensions.cs
1
using System.Linq.Expressions;
2
using LLL.AutoCompute.EFCore.Metadata.Internal;
3
using Microsoft.EntityFrameworkCore.Metadata.Builders;
4

5
namespace LLL.AutoCompute.EFCore;
6

7
public static class PropertyBuilderExtensions
8
{
9
    public static PropertyBuilder<TProperty> AutoCompute<TEntity, TProperty>(
10
        this PropertyBuilder<TProperty> propertyBuilder,
11
        Expression<Func<TEntity, TProperty>> computedExpression)
12
        where TEntity : class
13
    {
NEW
14
        return propertyBuilder.AutoCompute(computedExpression, static c => c.CurrentValue());
×
15
    }
16

17
    public static PropertyBuilder<TProperty> AutoCompute<TEntity, TProperty>(
18
        this PropertyBuilder<TProperty> propertyBuilder,
19
        Expression<Func<TEntity, TProperty>> computedExpression,
20
        ChangeCalculationSelector<TProperty, TProperty> calculationSelector)
21
        where TEntity : class
22
    {
23
        var changeCalculation = calculationSelector(ChangeCalculations<TProperty>.Instance);
12✔
24

25
        propertyBuilder.Metadata.AddComputedFactory(
12✔
26
            ComputedFactory.CreateComputedPropertyFactory(
12✔
27
                computedExpression,
12✔
28
                changeCalculation));
12✔
29

30
        return propertyBuilder;
12✔
31
    }
32

33
    public static PropertyBuilder<TProperty> Reaction<TEntity, TProperty, TValue>(
34
        this PropertyBuilder<TProperty> navigationBuilder,
35
        Expression<Func<TEntity, TValue>> computedExpression,
36
        Func<TProperty, TValue, TProperty> applyChange)
37
        where TEntity : class
38
    {
NEW
39
        return navigationBuilder.Reaction(computedExpression, static c => c.CurrentValue(), applyChange);
×
40
    }
41

42
    public static PropertyBuilder<TProperty> Reaction<TEntity, TProperty, TValue, TChange>(
43
        this PropertyBuilder<TProperty> navigationBuilder,
44
        Expression<Func<TEntity, TValue>> computedExpression,
45
        ChangeCalculationSelector<TValue, TChange> calculationSelector,
46
        Func<TProperty, TChange, TProperty> applyChange)
47
        where TEntity : class
48
    {
NEW
49
        var changeCalculation = calculationSelector(ChangeCalculations<TValue>.Instance);
×
50

NEW
51
        navigationBuilder.Metadata.AddComputedFactory(
×
NEW
52
            ComputedFactory.CreateComputedReactionFactory(
×
NEW
53
                computedExpression,
×
NEW
54
                changeCalculation,
×
NEW
55
                applyChange));
×
56

NEW
57
        return navigationBuilder;
×
58
    }
59
}
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