< Summary

Information
Class: Elsa.Persistence.EFCore.EntityHandlers.ApplyTenantId
Assembly: Elsa.Persistence.EFCore.Common
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.Common/EntityHandlers/ApplyTenantId.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 20
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
HandleAsync(...)0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.Common/EntityHandlers/ApplyTenantId.cs

#LineLine coverage
 1using Elsa.Common.Entities;
 2using Elsa.Extensions;
 3using Microsoft.EntityFrameworkCore.ChangeTracking;
 4
 5namespace Elsa.Persistence.EFCore.EntityHandlers;
 6
 7/// <summary>
 8/// Represents a handler for applying the tenant ID to an entity before saving changes.
 9/// </summary>
 10public class ApplyTenantId : IEntitySavingHandler
 11{
 12    /// <inheritdoc />
 13    public ValueTask HandleAsync(ElsaDbContextBase dbContext, EntityEntry entry, CancellationToken cancellationToken = d
 14    {
 015        if (entry.Entity is Entity entity)
 016            entity.TenantId = dbContext.TenantId.NullIfEmpty();
 17
 018        return default;
 19    }
 20}