iconDreamine
← 목록

Dreamine.Database.Sqlite

stablev1.0.1

SQLite 전용 드라이버 및 마이그레이션 지원.

#database#sqlite
TFM net8.0Package Dreamine.Database.Sqlite참조 Dreamine.Database.Abstractions, Dreamine.Database.Core

Dreamine.Database.Sqlite

Dreamine.Database.Sqlite는 Dreamine Database 패키지군의 SQLite Provider입니다.

English documentation

패키지 역할

이 패키지는 Microsoft.Data.Sqlite를 사용해서 SQLite용 IDatabaseProvider를 구현합니다.

Dreamine.Database.Abstractions
        ↑
Dreamine.Database.Core
        ↑
Dreamine.Database.Sqlite

외부 DB 서버 없이 바로 동작하기 때문에 SampleSmart Database 화면의 기본 Provider로 사용됩니다.

주요 기능

  • SQLite Connection 생성
  • SQLite Identifier Quote
  • SQLite Type Mapping
  • CREATE TABLE IF NOT EXISTS Table 생성
  • 공통 DatabaseProviderBase 기반 CRUD

빠른 시작

using Dreamine.Database.Sqlite;

var provider = new SqliteDatabaseProvider("Data Source=SampleSmart.db");

provider.EnsureDatabaseExists();
provider.CreateTable<SampleCustomer>();
provider.Insert(new SampleCustomer
{
    Name = "Dreamine",
    Role = "Operator",
    CreatedAt = DateTime.Now
});

var rows = provider.Query<SampleCustomer>(
    "SELECT Id, Name, Role, CreatedAt FROM SampleCustomers ORDER BY Id DESC");

의존성

  • Dreamine.Database.Abstractions
  • Dreamine.Database.Core
  • Microsoft.Data.Sqlite

대상 프레임워크

net8.0

샘플 및 테스트

  • 단위 테스트: 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 SqliteConnectionFactory {
        -string _dbPath
        +Create() IDbConnection
        +CreateAsync() Task~IDbConnection~
        +EnsureCreated() void
    }
    class SqliteRepository~T~ {
        +GetAsync(int) Task~T~
        +GetAllAsync() Task~IEnumerable~T~~
        +AddAsync(T) Task
        +UpdateAsync(T) Task
        +DeleteAsync(int) Task
    }
    class SqliteMigrator {
        +RunMigrationsAsync() Task
        +GetCurrentVersion() Task~int~
        -ApplyMigration(int) Task
    }
    class SqliteServiceExtensions {
        <<static>>
        +AddSqlite(IServiceCollection, string) IServiceCollection
    }
    class RepositoryBase~T~ {
        <<abstract>>
    }
    RepositoryBase~T~ <|-- SqliteRepository~T~
    SqliteRepository~T~ --> SqliteConnectionFactory
    SqliteMigrator --> SqliteConnectionFactory

API 문서

타입

SqliteDatabaseProvider

\if KO SQLite용 Dreamine 데이터베이스 공급자 구현을 제공합니다. \endif \if EN Provides a Dreamine database-provider implementation for SQLite. \endif

SqliteDatabaseProvider

#ctor Method

\if KO 지정한 연결 문자열로 의 새 인스턴스를 초기화합니다. \endif \if EN Initializes a new instance with the specified connection string. \endif

connectionString— \if KO SQLite 연결 문자열입니다. \endif \if EN The SQLite connection string. \endif
BuildPrimaryKeySql Method

\if KO 생성 키의 AUTOINCREMENT를 포함한 SQLite 기본 키 SQL을 만듭니다. \endif \if EN Builds SQLite primary-key SQL, including AUTOINCREMENT for generated keys. \endif

property— \if KO 기본 키 속성 매핑입니다. \endif \if EN The primary-key property mapping. \endif

반환: \if KO SQLite 기본 키 SQL 조각입니다. \endif \if EN The SQLite primary-key SQL fragment. \endif

CreateConnection Method

\if KO 구성된 연결 문자열을 사용하는 새 SQLite 연결을 만듭니다. \endif \if EN Creates a new SQLite connection using the configured connection string. \endif

반환: \if KO 닫힌 SQLite 연결입니다. \endif \if EN A closed SQLite connection. \endif

GetSqlType Method

\if KO CLR 속성 형식을 대응하는 SQLite 저장소 형식으로 변환합니다. \endif \if EN Converts a CLR property type to its corresponding SQLite storage type. \endif

property— \if KO 변환할 속성 매핑입니다. \endif \if EN The property mapping to convert. \endif

반환: \if KO SQLite 저장소 형식 선언입니다. \endif \if EN The SQLite storage-type declaration. \endif

IsTableExists Method

\if KO 현재 SQLite 데이터베이스에 지정한 테이블이 존재하는지 확인합니다. \endif \if EN Determines whether the specified table exists in the current SQLite database. \endif

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

반환: \if KO 테이블 존재 여부입니다. \endif \if EN Whether the table exists. \endif

IsTableExistsAsync Method

\if KO 현재 SQLite 데이터베이스에 지정한 테이블이 존재하는지 비동기적으로 확인합니다. \endif \if EN Asynchronously determines whether the specified table exists in the current SQLite database. \endif

tableName— \if KO 확인할 테이블 이름입니다. \endif \if EN The table name to inspect. \endif
cancellationToken— \if KO 조회 취소 토큰입니다. \endif \if EN A token used to cancel the query. \endif

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

QuoteIdentifier Method

\if KO SQLite 큰따옴표 문법으로 식별자를 안전하게 인용합니다. \endif \if EN Safely quotes an identifier using SQLite double-quote syntax. \endif

identifier— \if KO 인용할 식별자입니다. \endif \if EN The identifier to quote. \endif

반환: \if KO 이스케이프하고 인용한 식별자입니다. \endif \if EN The escaped and quoted identifier. \endif

Kind Property

\if KO SQLite 공급자 종류를 가져옵니다. \endif \if EN Gets the SQLite provider kind. \endif