using Blahblah.FlowerApp.Data.Model; using Microsoft.Extensions.Logging; using SQLite; namespace Blahblah.FlowerApp.Data; public class FlowerDatabase { private SQLiteAsyncConnection database = null!; private readonly ILogger logger; public FlowerDatabase(ILogger logger) { this.logger = logger; } private async Task Init() { if (database is not null) { return; } database = new SQLiteAsyncConnection(Constants.DatabasePath, Constants.SQLiteFlags); #if DEBUG var result = #endif await database.CreateTablesAsync(); #if DEBUG foreach (var item in result.Results) { logger.LogInformation("create table {table}, result: {result}", item.Key, item.Value); } #endif } public async Task GetFlowers() { await Init(); return await database.Table().ToArrayAsync(); } }