Na most kezd valami kinézni
This commit is contained in:
@@ -22,10 +22,13 @@ namespace WorkFlowCheck.MAUI.DataLayer
|
||||
public AppDbContext()
|
||||
{
|
||||
DbPath = Path.Combine(FileSystem.AppDataDirectory, "wfc.db");
|
||||
|
||||
}
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||
{
|
||||
options.UseSqlite($"Data Source={DbPath}");
|
||||
options.UseSqlite($"Data Source={DbPath};Foreign Keys=False;");
|
||||
options.EnableSensitiveDataLogging();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.MAUI.DataLayer.SQLiteFolder
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public const string DatabaseFilename = "WFC.db3";
|
||||
|
||||
public const SQLite.SQLiteOpenFlags Flags =
|
||||
// open the database in read/write mode
|
||||
SQLite.SQLiteOpenFlags.ReadWrite |
|
||||
// create the database if it doesn't exist
|
||||
SQLite.SQLiteOpenFlags.Create |
|
||||
// enable multi-threaded database access
|
||||
SQLite.SQLiteOpenFlags.SharedCache;
|
||||
|
||||
public static string DatabasePath =>
|
||||
Path.Combine(FileSystem.AppDataDirectory, DatabaseFilename);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using SQLite;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.MAUI.DataLayer.Entities;
|
||||
|
||||
namespace WorkFlowCheck.MAUI.DataLayer.SQLiteFolder
|
||||
{
|
||||
public class WFCDatabase
|
||||
{
|
||||
SQLiteAsyncConnection Database;
|
||||
public WFCDatabase()
|
||||
{
|
||||
}
|
||||
async Task Init()
|
||||
{
|
||||
if (Database is not null)
|
||||
return;
|
||||
|
||||
Database = new SQLiteAsyncConnection(Constants.DatabasePath, Constants.Flags);
|
||||
|
||||
var result = await Database.CreateTableAsync<CheckPoint>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user