< Summary

Information
Class: Elsa.Persistence.EFCore.Sqlite.SetupForSqlite
Assembly: Elsa.Persistence.EFCore.Sqlite
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.Sqlite/SetupForSqlite.cs
Line coverage
22%
Covered lines: 2
Uncovered lines: 7
Coverable lines: 9
Total lines: 30
Line coverage: 22.2%
Branch coverage
16%
Covered branches: 1
Total branches: 6
Branch coverage: 16.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Handle(...)16.66%23622.22%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.Sqlite/SetupForSqlite.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using Microsoft.EntityFrameworkCore.Metadata;
 3using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
 4
 5namespace Elsa.Persistence.EFCore.Sqlite;
 6
 7/// <summary>
 8/// Represents a class that handles entity model creation for SQLite databases.
 9/// </summary>
 10public class SetupForSqlite : IEntityModelCreatingHandler
 11{
 12    /// <inheritdoc />
 13    public void Handle(ElsaDbContextBase dbContext, ModelBuilder modelBuilder, IMutableEntityType entityType)
 14    {
 2915        if(!dbContext.Database.IsSqlite())
 2916            return;
 17
 18        // SQLite does not have proper support for DateTimeOffset via Entity Framework Core, see the limitations
 19        // here: https://docs.microsoft.com/en-us/ef/core/providers/sqlite/limitations#query-limitations
 020        var properties = entityType.ClrType.GetProperties().Where(p => p.PropertyType == typeof(DateTimeOffset) || p.Pro
 21
 022        foreach (var property in properties)
 23        {
 024            modelBuilder
 025                .Entity(entityType.Name)
 026                .Property(property.Name)
 027                .HasConversion(new DateTimeOffsetToStringConverter());
 28        }
 029    }
 30}