This commit is contained in:
2025-10-29 11:42:58 +08:00
parent 7f6f84cd0e
commit a178c3550e
190 changed files with 81361 additions and 92 deletions

View File

@@ -0,0 +1,33 @@
using FATrace.Com;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FATrace.App
{
public class FSqlContext
{
private static readonly Lazy<IFreeSql> LazyFreeSql = new Lazy<IFreeSql>(() =>
{
var connectionString = ConfigHelper.GetRequiredConnectionString("connecting");
try
{
return new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.SqlServer, connectionString)
.UseAutoSyncStructure(true)
.Build();
}
catch (Exception ex)
{
throw new InvalidOperationException("初始化数据库连接失败,请检查连接字符串与数据库网络连通性。", ex);
}
});
/// <summary>
/// 获取单例数据库实例。
/// </summary>
public static IFreeSql FDb => LazyFreeSql.Value;
}
}