mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-08 17:30:55 +08:00
update
28
常见问题.md
28
常见问题.md
@@ -1,10 +1,30 @@
|
|||||||
### 1、多个 IFreeSql 实例,如何注入使用?
|
### 1、如何监视 SQL?
|
||||||
|
|
||||||
|
方法一:UseMonitorCommand + UseNoneCommandParameter
|
||||||
|
```csharp
|
||||||
|
static IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=testdb;Charset=utf8;SslMode=none")
|
||||||
|
.UseMonitorCommand(cmd => Console.WriteLine($"线程:{cmd.CommandText}\r\n"))
|
||||||
|
.UseNoneCommandParameter(true)
|
||||||
|
.Build();
|
||||||
|
```
|
||||||
|
|
||||||
|
方法二:Aop.CurdBefore/CurdAfter
|
||||||
|
```csharp
|
||||||
|
Fsql.Aop.CurdAfter += (s, e) =>
|
||||||
|
{
|
||||||
|
if (e.ElapsedMilliseconds > 200)
|
||||||
|
Console.WriteLine($"线程:{e.Sql}\r\n")
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2、多个 IFreeSql 实例,如何注入使用?
|
||||||
|
|
||||||
[https://github.com/dotnetcore/FreeSql/issues/44](https://github.com/dotnetcore/FreeSql/issues/44)
|
[https://github.com/dotnetcore/FreeSql/issues/44](https://github.com/dotnetcore/FreeSql/issues/44)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### 2、怎么执行 SQL 返回实体列表?
|
### 3、怎么执行 SQL 返回实体列表?
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
//直接查询
|
//直接查询
|
||||||
@@ -16,13 +36,13 @@ fsql.Select<T>().WithSql(sql).Page(1, 10).ToList();
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### 3、错误:【主库】状态不可用,等待后台检查程序恢复方可使用。xxx
|
### 4、错误:【主库】状态不可用,等待后台检查程序恢复方可使用。xxx
|
||||||
|
|
||||||
一般是数据库连接失败,才会出现,请检查程序与数据库之间的网络。具体按 xxx 给出的提示进行排查。
|
一般是数据库连接失败,才会出现,请检查程序与数据库之间的网络。具体按 xxx 给出的提示进行排查。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### 4、错误:ObjectPool.Get 获取超时(10秒)。
|
### 5、错误:ObjectPool.Get 获取超时(10秒)。
|
||||||
|
|
||||||
原因一:UnitOfWork 使用未释放,请保证程序内使用 UnitOfWork 的地方会执行 Dispose
|
原因一:UnitOfWork 使用未释放,请保证程序内使用 UnitOfWork 的地方会执行 Dispose
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user