• 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/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<TEntity, TProperty, TProperty, TProperty>(
×
NEW
29
                computedExpression,
×
NEW
30
                changeCalculation,
×
NEW
31
                changeCalculation.ApplyChange));
×
32

NEW
33
        return navigationBuilder;
×
34
    }
35

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

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

NEW
56
        navigationBuilder.Metadata.AddComputedFactory(
×
NEW
57
            ComputedFactory.CreateComputedNavigationFactory(
×
NEW
58
                computedExpression,
×
NEW
59
                changeCalculation,
×
NEW
60
                mutator));
×
61

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