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

lucaslorentz / auto-compute / 11744711953

08 Nov 2024 03:11PM UTC coverage: 82.369%. First build
11744711953

push

github

lucaslorentz
Add initial support for computed navigations and observers

185 of 334 new or added lines in 17 files covered. (55.39%)

1509 of 1832 relevant lines covered (82.37%)

116.56 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, TReference> AutoCompute<TEntity, TReference>(
10
        this NavigationBuilder<TEntity, TReference> navigationBuilder,
11
        Expression<Func<TEntity, TReference>> computedExpression)
12
        where TEntity : class
13
        where TReference : class
14
    {
NEW
15
        return navigationBuilder.AutoCompute(computedExpression, static c => c.CurrentValue());
×
16
    }
17

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

NEW
27
        ComputedAnnotations.NavigationFactory.Set(
×
NEW
28
            navigationBuilder.Metadata,
×
NEW
29
            ComputedFactory.CreateComputedNavigationFactory(
×
NEW
30
                computedExpression,
×
NEW
31
                changeCalculation));
×
32

NEW
33
        return navigationBuilder;
×
34
    }
35

36
    public static NavigationBuilder<TEntity, TReference> Reaction<TEntity, TReference, TValue>(
37
        this NavigationBuilder<TEntity, TReference> navigationBuilder,
38
        Expression<Func<TEntity, TValue>> expression,
39
        Func<TReference, TValue, TReference> newValue)
40
        where TEntity : class
41
        where TReference : class
42
    {
43
        // builder.ComputedObserver(
44
        //     (Pack p) => p.CalcularTodasExecucoesAlocadas(),
45
        //     static c => c.CurrentValue(),
46
        //     static async (e, v) => e.TodasExecucoesAlocadasChanged(v)
47
        // );
NEW
48
        return navigationBuilder;
×
49
    }
50
}
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