< Summary

Information
Class: Elsa.Persistence.EFCore.Modules.Management.Configurations
Assembly: Elsa.Persistence.EFCore
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore/Modules/Management/Configurations.cs
Line coverage
100%
Covered lines: 41
Uncovered lines: 0
Coverable lines: 41
Total lines: 57
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_VersionToStringConverter()100%11100%
get_StringToVersionConverter()100%11100%
Configure(...)100%11100%
Configure(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore/Modules/Management/Configurations.cs

#LineLine coverage
 1using System.Linq.Expressions;
 2using Elsa.Workflows.Management.Entities;
 3using Microsoft.EntityFrameworkCore;
 4using Microsoft.EntityFrameworkCore.Metadata.Builders;
 5
 6namespace Elsa.Persistence.EFCore.Modules.Management;
 7
 8internal class Configurations : IEntityTypeConfiguration<WorkflowDefinition>, IEntityTypeConfiguration<WorkflowInstance>
 9{
 110    private static Expression<Func<Version?, string?>> VersionToStringConverter => v => v != null ? v.ToString() : null;
 111    private static Expression<Func<string?, Version?>> StringToVersionConverter => v => v != null ? Version.Parse(v) : n
 12
 13    public void Configure(EntityTypeBuilder<WorkflowDefinition> builder)
 14    {
 115        builder.Ignore(x => x.Variables);
 116        builder.Ignore(x => x.Inputs);
 117        builder.Ignore(x => x.Outputs);
 118        builder.Ignore(x => x.Outcomes);
 119        builder.Ignore(x => x.CustomProperties);
 120        builder.Ignore(x => x.Options);
 121        builder.Property<string>("Data");
 122        builder.Property<bool?>("UsableAsActivity");
 123        builder.Property(x => x.ToolVersion).HasConversion(VersionToStringConverter, StringToVersionConverter);
 124        builder.HasIndex(x => new {x.DefinitionId, x.Version}).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof
 125        builder.HasIndex(x => x.Version).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinition.Ve
 126        builder.HasIndex(x => x.Name).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinition.Name)
 127        builder.HasIndex(x => x.IsLatest).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinition.I
 128        builder.HasIndex(x => x.IsPublished).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinitio
 129        builder.HasIndex(x => x.IsSystem).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinition.I
 130        builder.HasIndex("UsableAsActivity").HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_UsableAsActivity");
 131        builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(WorkflowDefinition)}_{nameof(WorkflowDefinition.T
 132    }
 33
 34    public void Configure(EntityTypeBuilder<WorkflowInstance> builder)
 35    {
 136        builder.Ignore(x => x.WorkflowState);
 137        builder.Property<string>("Data");
 138        builder.Property<string>("DataCompressionAlgorithm");
 139        builder.Property(x => x.Status).HasConversion<string>();
 140        builder.Property(x => x.SubStatus).HasConversion<string>();
 141        builder.HasIndex(x => new { x.Status, x.SubStatus, x.DefinitionId, x.Version }).HasDatabaseName($"IX_{nameof(Wor
 142        builder.HasIndex(x => new { x.Status, x.SubStatus }).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(Wor
 143        builder.HasIndex(x => new { x.Status, x.DefinitionId }).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(
 144        builder.HasIndex(x => new { x.SubStatus, x.DefinitionId }).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{name
 145        builder.HasIndex(x => new { x.IsExecuting }).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowIns
 146        builder.HasIndex(x => x.DefinitionId).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.D
 147        builder.HasIndex(x => x.Status).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.Status)
 148        builder.HasIndex(x => x.SubStatus).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.SubS
 149        builder.HasIndex(x => x.CorrelationId).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.
 150        builder.HasIndex(x => x.Name).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.Name)}");
 151        builder.HasIndex(x => x.CreatedAt).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.Crea
 152        builder.HasIndex(x => x.UpdatedAt).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.Upda
 153        builder.HasIndex(x => x.FinishedAt).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.Fin
 154        builder.HasIndex(x => x.IsSystem).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.IsSys
 155        builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(WorkflowInstance)}_{nameof(WorkflowInstance.Tenan
 156    }
 57}