Files
admin/_docs/02_document/modules/common_database_schema_holder.md
T
2026-04-16 06:25:36 +03:00

1.4 KiB

Module: Azaion.Common.Database.AzaionDbSchemaHolder

Purpose

Static holder for the linq2db MappingSchema that maps C# entities to PostgreSQL table/column naming conventions and handles custom type conversions.

Public Interface

Member Type Description
MappingSchema static readonly MappingSchema Pre-built schema with column name and type mappings

Internal Logic

Static constructor:

  1. Creates a MappingSchema with a global callback that converts all column names to snake_case via StringExtensions.ToSnakeCase.
  2. Uses FluentMappingBuilder to configure the User entity:
    • Table name: "users"
    • Id: primary key, DataType.Guid
    • Role: stored as text, with custom conversion to/from RoleEnum via Enum.Parse
    • UserConfig: stored as nullable JSON text, serialized/deserialized via Newtonsoft.Json

Dependencies

  • User, RoleEnum entities
  • StringExtensions.ToSnakeCase
  • linq2db MappingSchema, FluentMappingBuilder
  • Newtonsoft.Json

Consumers

  • DbFactory.LoadOptions — passes MappingSchema to DataOptions.UseMappingSchema()

Data Models

Defines the ORM mapping for the users table.

Configuration

None — all mappings are compile-time.

External Integrations

None directly; mappings are used when queries execute against PostgreSQL.

Security

None.

Tests

None.