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

lucaslorentz / auto-compute / 11755625072

09 Nov 2024 10:48AM UTC coverage: 79.945% (-0.09%) from 80.033%
11755625072

push

github

lucaslorentz
Add initial support for computed navigations and observers

159 of 359 new or added lines in 22 files covered. (44.29%)

41 existing lines in 7 files now uncovered.

1459 of 1825 relevant lines covered (79.95%)

113.62 hits per line

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

0.0
/src/LLL.AutoCompute.EFCore/Extensions/NavigationBuilderExtensions.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 NavigationBuilderExtensions
8
{
9
    public static NavigationBuilder<TEntity, TProperty> AutoCompute<TEntity, TProperty>(
10
        this NavigationBuilder<TEntity, TProperty> navigationBuilder,
11
        Expression<Func<TEntity, TProperty>> computedExpression)
12
        where TEntity : class
13
        where TProperty : class
14
    {
NEW
15
        return navigationBuilder.AutoCompute(computedExpression, static c => c.CurrentValue());
×
16
    }
17

18
    public static NavigationBuilder<TEntity, TProperty> AutoCompute<TEntity, TProperty>(
19
        this NavigationBuilder<TEntity, TProperty> navigationBuilder,
20
        Expression<Func<TEntity, TProperty>> computedExpression,
21
        ChangeCalculationSelector<TProperty, TProperty> calculationSelector)
22
        where TEntity : class
23
        where TProperty : class
24
    {
NEW
25
        var changeCalculation = calculationSelector(ChangeCalculations<TProperty>.Instance);
×
26

NEW
27
        navigationBuilder.Metadata.AddComputedFactory(
×
NEW
28
            ComputedFactory.CreateComputedNavigationFactory(
×
NEW
29
                computedExpression,
×
NEW
30
                changeCalculation));
×
31

NEW
32
        return navigationBuilder;
×
33
    }
34

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

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

NEW
55
        navigationBuilder.Metadata.AddComputedFactory(
×
NEW
56
            ComputedFactory.CreateComputedReactionFactory(
×
NEW
57
                computedExpression,
×
NEW
58
                changeCalculation,
×
NEW
59
                applyChange));
×
60

NEW
61
        return navigationBuilder;
×
62
    }
63
}
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

© 2025 Coveralls, Inc