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

lucaslorentz / auto-compute / 11750234612

08 Nov 2024 10:06PM UTC coverage: 81.44% (-0.9%) from 82.369%
11750234612

push

github

lucaslorentz
Add initial support for computed navigations and observers

151 of 307 new or added lines in 14 files covered. (49.19%)

42 existing lines in 5 files now uncovered.

1448 of 1778 relevant lines covered (81.44%)

116.07 hits per line

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

43.75
/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<TEntity, TProperty, TProperty, TProperty>(
12✔
27
                computedExpression,
12✔
28
                changeCalculation,
12✔
29
                changeCalculation.ApplyChange));
12✔
30

31
        return propertyBuilder;
12✔
32
    }
33

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

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

NEW
52
        navigationBuilder.Metadata.AddComputedFactory(
×
NEW
53
            ComputedFactory.CreateComputedPropertyFactory(
×
NEW
54
                computedExpression,
×
NEW
55
                changeCalculation,
×
NEW
56
                mutator));
×
57

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