docs: update doc

This commit is contained in:
wintel
2025-04-26 11:57:13 +08:00
parent 8c129d6746
commit 107e297e01
14 changed files with 76 additions and 47 deletions

View File

@@ -4,8 +4,16 @@ createTime: 2025/04/23 21:03:10
permalink: /core/sqlsugar/
---
SqlSugar 是一款老牌.NET开源ORM框架相对于EntityFramework复杂的Linq表达式它拥有灵活的动态查询如果你喜欢直接码Sql那么它是你的不二之选。OpenAuth.Net 6.0及以后版本默认支持使用SqlSugar方式访问数据库。目前大多数模块都已使用SqlSugar的方式这里以资源管理为例
SqlSugar 是一款老牌.NET开源ORM框架相对于EntityFramework复杂的Linq表达式它拥有灵活的动态查询如果你喜欢直接码Sql那么它是你的不二之选。OpenAuth.Net 6.0及以后版本默认支持使用SqlSugar方式访问数据库。
框架提供`SqlSugarBaseApp`基类该基类定义了SqlSugar最常用的两个成员变量
```csharp
protected ISqlSugarClient SugarClient; //SqlSugar基础数据库读写
protected SqlSugarRepository<T> Repository; //SqlSugar的仓储模式
```
只需要继承该基类即可使用SqlSugar的强大功能。
目前框架大多数模块都已继承`SqlSugarBaseApp`基类,这里以资源管理为例:
```csharp
public class ResourceApp:SqlSugarBaseApp<Resource>
{
@@ -39,9 +47,10 @@ public class ResourceApp:SqlSugarBaseApp<Resource>
## 使用方法
如上所示代码,只需要继承`SqlSugarBaseApp`即可使用SqlSugar强大功能。其中
当编写业务代码需要使用SqlSugar的模块时,只需要继承`SqlSugarBaseApp`即可使用SqlSugar强大功能。其中
Repository实现的是SqlSugar的仓储模式详细Api请查看[SqlSugar使用仓储](https://www.donet5.com/Home/Doc?typeId=1228)。在OpenAuth.Net中
### Repository
实现的是SqlSugar的仓储模式详细Api请查看[SqlSugar使用仓储](https://www.donet5.com/Home/Doc?typeId=1228)。在OpenAuth.Net中
```csharp
public class ResourceApp:SqlSugarBaseApp<Resource>
{
@@ -52,8 +61,8 @@ public class ResourceApp:SqlSugarBaseApp<Resource>
}
}
```
SugarClientSqlSugar基础数据库读写用法。详细Api请查看[SqlSugar入门必看](https://www.donet5.com/Home/Doc?typeId=1181)。在OpenAuth.Net中
### SugarClient
SqlSugar基础数据库读写用法。详细Api请查看[SqlSugar入门必看](https://www.donet5.com/Home/Doc?typeId=1181)。在OpenAuth.Net中
```csharp
public class ResourceApp:SqlSugarBaseApp<Resource>
{