iconDreamine
← 목록

Dreamine.Database.Abstractions

stablev1.0.1

데이터베이스 공통 추상화 — IDbConnectionFactory, ITransaction 인터페이스.

#database#abstractions
TFM net8.0Package Dreamine.Database.Abstractions

Dreamine.Database.Abstractions

Dreamine.Database.Abstractions는 Dreamine Database 패키지군에서 공통으로 사용하는 Provider 중립 계약 레이어입니다.

English documentation

패키지 역할

이 패키지는 Database 계층의 최하위 계약 레이어입니다. 공통 옵션, Provider 식별자, Mapping Attribute, IDatabaseProvider CRUD 계약만 포함합니다.

Application / Samples / Tests
        ↓
Dreamine.Database.Abstractions
        ↑
Database.Core / SQLite / MySQL / Oracle / SQL Server

구체 Database Provider는 애플리케이션 코드에 벤더 전용 API를 노출하지 않고 이 패키지의 계약에 의존해야 합니다.

주요 기능

  • IDatabaseProvider 공통 CRUD 계약
  • DatabaseProviderKind Provider 식별자
  • DatabaseConnectionOptions 연결 메타데이터
  • Table, Key, Generated, Ignore, Column Name 매핑 Attribute
  • Database 초기화, Table 확인, Command, Scalar Query, Read, Insert, Update, Delete 동기/비동기 API

Mapping Attribute

Attribute 역할
DatabaseTableAttribute Entity의 Table 이름을 재정의합니다.
DatabaseColumnAttribute Property의 Column 이름을 재정의합니다.
DatabaseKeyAttribute Primary Key Property를 표시합니다.
DatabaseGeneratedAttribute Database에서 생성되는 Key Column을 표시합니다.
DatabaseIgnoreAttribute Property를 Database Mapping에서 제외합니다.

최소 Entity 예시

using Dreamine.Database.Abstractions.Mapping;

[DatabaseTable("SampleCustomers")]
public sealed class SampleCustomer
{
    [DatabaseKey]
    [DatabaseGenerated]
    public int Id { get; set; }

    public string Name { get; set; } = string.Empty;

    public string Role { get; set; } = string.Empty;

    public DateTime CreatedAt { get; set; }
}

설계 원칙

  • 애플리케이션 코드를 구체 DB Driver에서 분리합니다.
  • Mapping Metadata를 작고 Attribute 기반으로 유지합니다.
  • SQLite, MySQL, Oracle, SQL Server에서 일관된 Provider API를 제공합니다.
  • 계약 패키지에는 Dapper 또는 벤더 Driver 의존성을 넣지 않습니다.

의존성

없음.

대상 프레임워크

net8.0

관련 패키지

  • Dreamine.Database.Core
  • Dreamine.Database.Sqlite
  • Dreamine.Database.MySql
  • Dreamine.Database.Oracle
  • Dreamine.Database.SqlServer

샘플 및 테스트

  • 단위 테스트: 20_SOURCES/200. Tests/Dreamine.FullKit.Tests/Database
  • WPF 샘플: 20_SOURCES/998. DEMO/000. Sample/010. Wpfs/SampleSmart/Pages/PageSub/PageDatabase.xaml

라이선스

MIT License

구조 다이어그램

classDiagram
    class IRepository~T~ {
        <<interface>>
        +GetAsync(int) Task~T~
        +GetAllAsync() Task~IEnumerable~T~~
        +FindAsync(Expression) Task~IEnumerable~T~~
        +AddAsync(T) Task
        +UpdateAsync(T) Task
        +DeleteAsync(int) Task
    }
    class IUnitOfWork {
        <<interface>>
        +BeginTransaction() Task
        +CommitAsync() Task
        +RollbackAsync() Task
        +SaveChangesAsync() Task~int~
    }
    class IDbConnectionFactory {
        <<interface>>
        +Create() IDbConnection
        +CreateAsync() Task~IDbConnection~
    }
    class IQueryBuilder~T~ {
        <<interface>>
        +Where(Expression) IQueryBuilder~T~
        +OrderBy(Expression) IQueryBuilder~T~
        +Take(int) IQueryBuilder~T~
        +Skip(int) IQueryBuilder~T~
        +ToListAsync() Task~IEnumerable~T~~
    }
    class IEntity {
        <<interface>>
        +int Id
        +DateTime CreatedAt
        +DateTime? UpdatedAt
    }
    IRepository~T~ --> IEntity
    IUnitOfWork --> IRepository~T~

API 문서

타입

DatabaseColumnAttribute

\if KO 엔터티 속성을 지정한 데이터베이스 열 이름에 매핑합니다. \endif \if EN Maps an entity property to the specified database column name. \endif

DatabaseConnectionOptions

\if KO Dreamine 데이터베이스 공급자가 사용할 연결 설정을 제공합니다. \endif \if EN Provides connection settings for a Dreamine database provider. \endif

DatabaseGeneratedAttribute

\if KO 엔터티 속성 값이 데이터베이스에서 생성됨을 나타냅니다. \endif \if EN Indicates that an entity-property value is generated by the database. \endif

DatabaseIgnoreAttribute

\if KO 데이터베이스 매핑에서 엔터티 속성을 제외합니다. \endif \if EN Excludes an entity property from database mapping. \endif

DatabaseKeyAttribute

\if KO 엔터티 속성을 데이터베이스 기본 키로 표시합니다. \endif \if EN Marks an entity property as a database primary key. \endif

DatabaseProviderKind

\if KO 데이터베이스 공급자 제품군을 식별합니다. \endif \if EN Identifies the database provider family. \endif

DatabaseTableAttribute

\if KO 엔터티 형식을 지정한 데이터베이스 테이블 이름에 매핑합니다. \endif \if EN Maps an entity type to the specified database table name. \endif

IDatabaseCommandExecutor

\if KO 원시 SQL 명령 실행 작업을 정의합니다. \endif \if EN Defines raw SQL command execution operations. \endif

IDatabaseConnection

\if KO 데이터베이스 공급자 식별 정보와 연결 구성을 정의합니다. \endif \if EN Defines database-provider identity and connection configuration. \endif

IDatabaseProvider

\if KO Dreamine 공급자가 지원하는 전체 데이터베이스 기능 표면을 정의합니다. \endif \if EN Defines the complete database capability surface supported by Dreamine providers. \endif

IDatabaseQueryProvider

\if KO 원시 SQL 조회 작업을 정의합니다. \endif \if EN Defines raw SQL query operations. \endif

IDatabaseRepository

\if KO 매핑된 엔터티의 데이터 조작 작업을 정의합니다. \endif \if EN Defines data-manipulation operations for mapped entities. \endif

IDatabaseSchemaProvider

\if KO 데이터베이스 스키마와 테이블 관리 작업을 정의합니다. \endif \if EN Defines database-schema and table-management operations. \endif

DatabaseColumnAttribute

#ctor Method

\if KO 지정한 열 이름으로 특성을 초기화합니다. \endif \if EN Initializes the attribute with the specified column name. \endif

name— \if KO 엔터티 속성에 매핑할 데이터베이스 열 이름입니다. \endif \if EN The database column name mapped to the entity property. \endif
Name Property

\if KO 매핑된 데이터베이스 열 이름을 가져옵니다. \endif \if EN Gets the mapped database column name. \endif

DatabaseConnectionOptions

#ctor Method

\if KO 지정한 연결 문자열로 새 연결 설정을 초기화합니다. \endif \if EN Initializes connection settings with the specified connection string. \endif

connectionString— \if KO 공급자에 전달할 데이터베이스 연결 문자열입니다. \endif \if EN The database connection string to pass to the provider. \endif
ConnectionString Property

\if KO 공급자에 전달할 데이터베이스 연결 문자열을 가져옵니다. \endif \if EN Gets the database connection string passed to the provider. \endif

DatabaseProviderKind

MySql Field

\if KO MySQL 데이터베이스 공급자입니다. \endif \if EN The MySQL database provider. \endif

Oracle Field

\if KO Oracle 데이터베이스 공급자입니다. \endif \if EN The Oracle database provider. \endif

Sqlite Field

\if KO SQLite 데이터베이스 공급자입니다. \endif \if EN The SQLite database provider. \endif

SqlServer Field

\if KO Microsoft SQL Server 데이터베이스 공급자입니다. \endif \if EN The Microsoft SQL Server database provider. \endif

Unknown Field

\if KO 공급자 종류를 알 수 없거나 지정하지 않았습니다. \endif \if EN The provider kind is unknown or unspecified. \endif

DatabaseTableAttribute

#ctor Method

\if KO 지정한 테이블 이름으로 특성을 초기화합니다. \endif \if EN Initializes the attribute with the specified table name. \endif

name— \if KO 엔터티 형식에 매핑할 데이터베이스 테이블 이름입니다. \endif \if EN The database table name mapped to the entity type. \endif
Name Property

\if KO 매핑된 데이터베이스 테이블 이름을 가져옵니다. \endif \if EN Gets the mapped database table name. \endif

IDatabaseCommandExecutor

ExecuteNonQuery Method

\if KO 원시 SQL 명령을 동기적으로 실행합니다. \endif \if EN Executes a raw SQL command synchronously. \endif

sql— \if KO 실행할 SQL 명령문입니다. \endif \if EN The SQL command text to execute. \endif
parameters— \if KO 선택적 명령 매개 변수 객체입니다. \endif \if EN The optional command-parameter object. \endif

반환: \if KO 명령의 영향을 받은 행 수입니다. \endif \if EN The number of rows affected by the command. \endif

ExecuteNonQueryAsync Method

\if KO 원시 SQL 명령을 비동기적으로 실행합니다. \endif \if EN Executes a raw SQL command asynchronously. \endif

sql— \if KO 실행할 SQL 명령문입니다. \endif \if EN The SQL command text to execute. \endif
parameters— \if KO 선택적 명령 매개 변수 객체입니다. \endif \if EN The optional command-parameter object. \endif
cancellationToken— \if KO 비동기 작업 취소를 요청하는 토큰입니다. \endif \if EN A token used to request cancellation of the asynchronous operation. \endif

반환: \if KO 영향을 받은 행 수를 결과로 제공하는 작업입니다. \endif \if EN A task whose result is the number of affected rows. \endif

ExecuteScalar``1 Method

\if KO 원시 SQL 스칼라 명령을 동기적으로 실행합니다. \endif \if EN Executes a raw SQL scalar command synchronously. \endif

sql— \if KO 실행할 SQL 명령문입니다. \endif \if EN The SQL command text to execute. \endif
parameters— \if KO 선택적 명령 매개 변수 객체입니다. \endif \if EN The optional command-parameter object. \endif

반환: \if KO 변환된 스칼라 값이며 결과가 없으면 일 수 있습니다. \endif \if EN The converted scalar value, or possibly when no value is available. \endif

ExecuteScalarAsync``1 Method

\if KO 원시 SQL 스칼라 명령을 비동기적으로 실행합니다. \endif \if EN Executes a raw SQL scalar command asynchronously. \endif

sql— \if KO 실행할 SQL 명령문입니다. \endif \if EN The SQL command text to execute. \endif
parameters— \if KO 선택적 명령 매개 변수 객체입니다. \endif \if EN The optional command-parameter object. \endif
cancellationToken— \if KO 비동기 작업 취소를 요청하는 토큰입니다. \endif \if EN A token used to request cancellation of the asynchronous operation. \endif

반환: \if KO 변환된 스칼라 값 또는 값이 없을 때 을 결과로 제공하는 작업입니다. \endif \if EN A task whose result is the converted scalar value, or possibly when no value is available. \endif

IDatabaseConnection

EnsureDatabaseExists Method

\if KO 공급자가 대상 데이터베이스를 열거나 필요한 경우 생성할 수 있도록 보장합니다. \endif \if EN Ensures that the provider can open or, when necessary, create the target database. \endif

EnsureDatabaseExistsAsync Method

\if KO 공급자가 대상 데이터베이스를 열거나 필요한 경우 생성할 수 있도록 비동기적으로 보장합니다. \endif \if EN Asynchronously ensures that the provider can open or, when necessary, create the target database. \endif

cancellationToken— \if KO 작업 취소를 요청하는 토큰입니다. \endif \if EN A token used to request cancellation of the operation. \endif

반환: \if KO 데이터베이스 확인 또는 생성 작업을 나타냅니다. \endif \if EN A task that represents the database verification or creation operation. \endif

ConnectionString Property

\if KO 공급자가 사용하는 연결 문자열을 가져옵니다. \endif \if EN Gets the connection string used by the provider. \endif

Kind Property

\if KO 데이터베이스 공급자 종류를 가져옵니다. \endif \if EN Gets the database provider kind. \endif

IDatabaseQueryProvider

Query``1 Method

\if KO 원시 SQL 조회를 동기적으로 실행합니다. \endif \if EN Executes a raw SQL query synchronously. \endif

sql— \if KO 실행할 SQL 조회문입니다. \endif \if EN The SQL query text to execute. \endif
parameters— \if KO 선택적 조회 매개 변수 객체입니다. \endif \if EN The optional query-parameter object. \endif

반환: \if KO 로 매핑된 조회 행 시퀀스입니다. \endif \if EN A sequence of query rows mapped to . \endif

QueryAsync``1 Method

\if KO 원시 SQL 조회를 비동기적으로 실행합니다. \endif \if EN Executes a raw SQL query asynchronously. \endif

sql— \if KO 실행할 SQL 조회문입니다. \endif \if EN The SQL query text to execute. \endif
parameters— \if KO 선택적 조회 매개 변수 객체입니다. \endif \if EN The optional query-parameter object. \endif
cancellationToken— \if KO 비동기 조회 취소를 요청하는 토큰입니다. \endif \if EN A token used to request cancellation of the asynchronous query. \endif

반환: \if KO 로 매핑된 조회 행의 읽기 전용 목록을 결과로 제공하는 작업입니다. \endif \if EN A task whose result is a read-only list of query rows mapped to . \endif

IDatabaseRepository

Delete``1 Method

\if KO 엔터티를 동기적으로 삭제합니다. \endif \if EN Deletes an entity synchronously. \endif

entity— \if KO 삭제할 엔터티 인스턴스입니다. \endif \if EN The entity instance to delete. \endif

반환: \if KO 하나 이상의 행을 삭제했으면 , 그렇지 않으면 입니다. \endif \if EN when at least one row was deleted; otherwise, . \endif

DeleteAsync``1 Method

\if KO 엔터티를 비동기적으로 삭제합니다. \endif \if EN Deletes an entity asynchronously. \endif

entity— \if KO 삭제할 엔터티 인스턴스입니다. \endif \if EN The entity instance to delete. \endif
cancellationToken— \if KO 삭제 작업 취소를 요청하는 토큰입니다. \endif \if EN A token used to request cancellation of the delete operation. \endif

반환: \if KO 하나 이상의 행을 삭제했는지를 결과로 제공하는 작업입니다. \endif \if EN A task whose result indicates whether at least one row was deleted. \endif

Insert``1 Method

\if KO 엔터티를 동기적으로 삽입합니다. \endif \if EN Inserts an entity synchronously. \endif

entity— \if KO 삽입할 엔터티 인스턴스입니다. \endif \if EN The entity instance to insert. \endif

반환: \if KO 하나 이상의 행을 삽입했으면 , 그렇지 않으면 입니다. \endif \if EN when at least one row was inserted; otherwise, . \endif

InsertAsync``1 Method

\if KO 엔터티를 비동기적으로 삽입합니다. \endif \if EN Inserts an entity asynchronously. \endif

entity— \if KO 삽입할 엔터티 인스턴스입니다. \endif \if EN The entity instance to insert. \endif
cancellationToken— \if KO 삽입 작업 취소를 요청하는 토큰입니다. \endif \if EN A token used to request cancellation of the insert operation. \endif

반환: \if KO 하나 이상의 행을 삽입했는지를 결과로 제공하는 작업입니다. \endif \if EN A task whose result indicates whether at least one row was inserted. \endif

Update``1 Method

\if KO 엔터티를 동기적으로 갱신합니다. \endif \if EN Updates an entity synchronously. \endif

entity— \if KO 갱신할 엔터티 인스턴스입니다. \endif \if EN The entity instance to update. \endif

반환: \if KO 하나 이상의 행을 갱신했으면 , 그렇지 않으면 입니다. \endif \if EN when at least one row was updated; otherwise, . \endif

UpdateAsync``1 Method

\if KO 엔터티를 비동기적으로 갱신합니다. \endif \if EN Updates an entity asynchronously. \endif

entity— \if KO 갱신할 엔터티 인스턴스입니다. \endif \if EN The entity instance to update. \endif
cancellationToken— \if KO 갱신 작업 취소를 요청하는 토큰입니다. \endif \if EN A token used to request cancellation of the update operation. \endif

반환: \if KO 하나 이상의 행을 갱신했는지를 결과로 제공하는 작업입니다. \endif \if EN A task whose result indicates whether at least one row was updated. \endif

IDatabaseSchemaProvider

CreateTable``1 Method

\if KO 엔터티 형식에 매핑된 테이블이 없으면 동기적으로 생성합니다. \endif \if EN Synchronously creates the table mapped to an entity type when it does not exist. \endif

CreateTableAsync``1 Method

\if KO 엔터티 형식에 매핑된 테이블이 없으면 비동기적으로 생성합니다. \endif \if EN Asynchronously creates the table mapped to an entity type when it does not exist. \endif

cancellationToken— \if KO 생성 작업 취소를 요청하는 토큰입니다. \endif \if EN A token used to request cancellation of the creation operation. \endif

반환: \if KO 테이블 생성 작업을 나타냅니다. \endif \if EN A task that represents the table-creation operation. \endif

IsTableExists Method

\if KO 지정한 이름의 테이블이 존재하는지 동기적으로 확인합니다. \endif \if EN Synchronously determines whether a table with the specified name exists. \endif

tableName— \if KO 확인할 테이블 이름입니다. \endif \if EN The table name to inspect. \endif

반환: \if KO 테이블이 존재하면 , 그렇지 않으면 입니다. \endif \if EN when the table exists; otherwise, . \endif

IsTableExists``1 Method

\if KO 엔터티 형식에 매핑된 테이블이 존재하는지 동기적으로 확인합니다. \endif \if EN Synchronously determines whether the table mapped to an entity type exists. \endif

반환: \if KO 매핑된 테이블이 존재하면 , 그렇지 않으면 입니다. \endif \if EN when the mapped table exists; otherwise, . \endif

IsTableExistsAsync Method

\if KO 지정한 이름의 테이블이 존재하는지 비동기적으로 확인합니다. \endif \if EN Asynchronously determines whether a table with the specified name exists. \endif

tableName— \if KO 확인할 테이블 이름입니다. \endif \if EN The table name to inspect. \endif
cancellationToken— \if KO 확인 작업 취소를 요청하는 토큰입니다. \endif \if EN A token used to request cancellation of the inspection. \endif

반환: \if KO 테이블 존재 여부를 결과로 제공하는 작업입니다. \endif \if EN A task whose result indicates whether the table exists. \endif

IsTableExistsAsync``1 Method

\if KO 엔터티 형식에 매핑된 테이블이 존재하는지 비동기적으로 확인합니다. \endif \if EN Asynchronously determines whether the table mapped to an entity type exists. \endif

cancellationToken— \if KO 확인 작업 취소를 요청하는 토큰입니다. \endif \if EN A token used to request cancellation of the inspection. \endif

반환: \if KO 매핑된 테이블 존재 여부를 결과로 제공하는 작업입니다. \endif \if EN A task whose result indicates whether the mapped table exists. \endif