using System.Runtime.CompilerServices;

namespace KArtSell.BuildingBlocks.Data;

/// <summary>
/// Dapper does not map snake_case DB columns (event_type) to PascalCase C# properties
/// (EventType) by default; every Sql class in this repo relies on that mapping, so this
/// must be set before any query runs. A module initializer guarantees it runs once per
/// process regardless of entry point (Host, DbMigrator, test runner) without every Sql
/// class or Program.cs having to remember to configure it.
/// </summary>
internal static class DapperBootstrap
{
#pragma warning disable CA2255 // intentional: BuildingBlocks is this solution's internal shared layer,
    // not a distributed package, and every entry point (Host/DbMigrator/tests) needs this set
    // before its first query regardless of which one runs first.
    [ModuleInitializer]
#pragma warning restore CA2255
    public static void Initialize()
    {
        Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true;
    }
}
