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

lucaslorentz / auto-compute / 11758855041

09 Nov 2024 07:22PM UTC coverage: 77.28% (+0.07%) from 77.208%
11758855041

push

github

lucaslorentz
Add initial support for computed navigations and observers

166 of 431 new or added lines in 25 files covered. (38.52%)

41 existing lines in 7 files now uncovered.

1466 of 1897 relevant lines covered (77.28%)

109.91 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