Commit ba980501 authored by 潘栩锋's avatar 潘栩锋 🚴

修改 SQLiteDbContext InitNoBuild() 当只是数据库少了个表,自动添加进去。 当正常加载成功

parent 5ed48454
...@@ -214,15 +214,35 @@ namespace SQLite ...@@ -214,15 +214,35 @@ namespace SQLite
{ {
ddls.Add(tb.TableName, tb.DDL); ddls.Add(tb.TableName, tb.DDL);
} }
if (sqliteHelper.IsTableValid(ddls))
{ bool isVaild = sqliteHelper.IsTableValid(ddls, out Dictionary<string, SQLiteHelper.IsTableValidResult> results);
Load();
return true; if (!isVaild)//不合法
}
else
{ {
return false; if (results.Any(kv => kv.Value == SQLiteHelper.IsTableValidResult.FormatErr))
{
//格式不对,无法容忍
return false;
}
//有表 不对
foreach (var kv in results)
{
switch (kv.Value)
{
case SQLiteHelper.IsTableValidResult.NotHere:
{
//直接创建表
sqliteHelper.ExecuteNonQuery(ddls[kv.Key]);
}
break;
}
}
} }
Load();
return true;
} }
/// <summary> /// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment