From 8427804581f790b6503dd482e026f04ffd04fdc7 Mon Sep 17 00:00:00 2001 From: xxe Date: Wed, 12 Oct 2022 17:53:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=93=BE=E6=8E=A5=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HKLib/DB/DbContext.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/HKLib/DB/DbContext.cs b/HKLib/DB/DbContext.cs index 52f6806..4a46eb4 100644 --- a/HKLib/DB/DbContext.cs +++ b/HKLib/DB/DbContext.cs @@ -15,7 +15,7 @@ namespace HKLib.DB { public static SqlSugarScope Context = new SqlSugarScope(new ConnectionConfig() { - ConnectionString = Route(), + ConnectionString = Route, DbType = DbType.Sqlite,//数据库类型 IsAutoCloseConnection = true //不设成true要手动close }, db => @@ -26,11 +26,13 @@ namespace HKLib.DB }; }); - static string Route() + public static string Route { - var dir = SyncStatic.CreateDir(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Database")); - var r= SyncStatic.CreateFile(Path.Combine(dir, "data.db3")); - return r; + get + { + var dir = SyncStatic.CreateDir(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Database")); + return $"DataSource={SyncStatic.CreateFile(Path.Combine(dir, "Data.db3"))}"; + } } public static void InitTable() {