Skip to content

Commit

Permalink
🚥 publish 1.19.0 version.
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkSoul committed Apr 11, 2021
1 parent f3e4ae6 commit b3d5b80
Show file tree
Hide file tree
Showing 31 changed files with 287 additions and 66 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## v1.19.0 (未发布
## v1.19.0 (当前版本

- **新特性**

Expand All @@ -19,14 +19,18 @@
- [修复] 多数据库工作单元异常无法回滚数据 [#I3I2KN](https://gitee.com/dotnetchina/Furion/issues/I3I2KN) [#I3HYN5](https://gitee.com/zuohuaijun/Admin.NET/issues/I3HYN5)
- [修复] Serilog 日志生成太多文件 [#I3I2PN](https://gitee.com/dotnetchina/Furion/issues/I3I2PN)
- [修复] `1.18.0` 版本数据库连接池存在连接泄漏问题 [#I3I5KO](https://gitee.com/dotnetchina/Furion/issues/I3I5KO)
- [修复] Sqlite 提示事务已完成异常 [#I3I9F2](https://gitee.com/dotnetchina/Furion/issues/I3I9F2)

- **其他更改**

- [改进] 视图模板功能,默认支持可枚举泛型类型 [#I3GYEE](https://gitee.com/dotnetchina/Furion/issues/I3GYEE)
- [改进] 开发阶段 MiniProfiler 打印数据库相关信息 [#I3I8VQ](https://gitee.com/dotnetchina/Furion/issues/I3I8VQ)
- [改进] EFCore 5.0 未提供 Sqlite 数据库 DataAdapter 的支持 [#I3I9FC](https://gitee.com/dotnetchina/Furion/issues/I3I9FC)

- **文档变化**

- [更新] 数据库上下文、多租户、仓储、日志、序列化等文档。

- **问答答疑**

- [答疑] 建议 MVC 模式下增加 Furion 的功能 [#I3GY4R](https://gitee.com/dotnetchina/Furion/issues/I3GY4R)
Expand All @@ -40,7 +44,7 @@

---

## v1.18.0 (当前版本
## v1.18.0 (已发布

- **新特性**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<version>1.18.9</version>
<version>1.19.0</version>
<Description>Furion Jwt 授权验证拓展插件。</Description>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Furion.Extras.Web.HttpContext" Version="1.18.9" />
<PackageReference Include="Furion.Extras.Web.HttpContext" Version="1.19.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.5" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<version>1.18.9</version>
<version>1.19.0</version>
<Description>Furion 数据库访问器 Dapper 插件。</Description>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<version>1.18.9</version>
<version>1.19.0</version>
<Description>Furion 数据库访问器 PetaPoco 插件。</Description>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<version>1.18.9</version>
<version>1.19.0</version>
<Description>Furion 数据库访问器 SqlSugar 插件。</Description>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<version>1.18.9</version>
<version>1.19.0</version>
<Description>Furion 程序集扫描和代码分析拓展插件。</Description>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<version>1.18.9</version>
<version>1.19.0</version>
<Description>Furion 日志记录 Serilog 插件。</Description>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<version>1.18.9</version>
<version>1.19.0</version>
<Description>Furion 对象映射 Mapster 插件。</Description>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<version>1.18.9</version>
<version>1.19.0</version>
<Description>Furion HttpContext 插件。</Description>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static (DbConnection dbConnection, DbCommand dbCommand, DbParameter[] dbP
/// <param name="parameters">命令参数</param>
/// <param name="commandType">命令类型</param>
/// <returns>(DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbDataAdapter)</returns>
public static (DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbDataAdapter) PrepareDbDbDataAdapter(this DatabaseFacade databaseFacade, string sql, DbParameter[] parameters = null, CommandType commandType = CommandType.Text)
public static (DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbDataAdapter) PrepareDbDataAdapter(this DatabaseFacade databaseFacade, string sql, DbParameter[] parameters = null, CommandType commandType = CommandType.Text)
{
// 创建数据库连接对象、数据库命令对象和数据库适配器对象
var (dbConnection, dbCommand, dbDataAdapter) = databaseFacade.CreateDbDataAdapter(sql, commandType);
Expand All @@ -165,7 +165,7 @@ public static (DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbD
/// <param name="model">命令模型</param>
/// <param name="commandType">命令类型</param>
/// <returns>(DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbDataAdapter, DbParameter[] dbParameters)</returns>
public static (DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbDataAdapter, DbParameter[] dbParameters) PrepareDbDbDataAdapter(this DatabaseFacade databaseFacade, string sql, object model, CommandType commandType = CommandType.Text)
public static (DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbDataAdapter, DbParameter[] dbParameters) PrepareDbDataAdapter(this DatabaseFacade databaseFacade, string sql, object model, CommandType commandType = CommandType.Text)
{
// 创建数据库连接对象、数据库命令对象和数据库适配器对象
var (dbConnection, dbCommand, dbDataAdapter) = databaseFacade.CreateDbDataAdapter(sql, commandType);
Expand All @@ -187,7 +187,7 @@ public static (DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbD
/// <param name="commandType">命令类型</param>
/// <param name="cancellationToken">异步取消令牌</param>
/// <returns>(DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbDataAdapter)</returns>
public static async Task<(DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbDataAdapter)> PrepareDbDbDataAdapterAsync(this DatabaseFacade databaseFacade, string sql, DbParameter[] parameters = null, CommandType commandType = CommandType.Text, CancellationToken cancellationToken = default)
public static async Task<(DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbDataAdapter)> PrepareDbDataAdapterAsync(this DatabaseFacade databaseFacade, string sql, DbParameter[] parameters = null, CommandType commandType = CommandType.Text, CancellationToken cancellationToken = default)
{
// 创建数据库连接对象、数据库命令对象和数据库适配器对象
var (dbConnection, dbCommand, dbDataAdapter) = databaseFacade.CreateDbDataAdapter(sql, commandType);
Expand All @@ -209,7 +209,7 @@ public static (DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbD
/// <param name="commandType">命令类型</param>
/// <param name="cancellationToken">异步取消令牌</param>
/// <returns>(DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbDataAdapter, DbParameter[] dbParameters)</returns>
public static async Task<(DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbDataAdapter, DbParameter[] dbParameters)> PrepareDbDbDataAdapterAsync(this DatabaseFacade databaseFacade, string sql, object model, CommandType commandType = CommandType.Text, CancellationToken cancellationToken = default)
public static async Task<(DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter dbDataAdapter, DbParameter[] dbParameters)> PrepareDbDataAdapterAsync(this DatabaseFacade databaseFacade, string sql, object model, CommandType commandType = CommandType.Text, CancellationToken cancellationToken = default)
{
// 创建数据库连接对象、数据库命令对象和数据库适配器对象
var (dbConnection, dbCommand, dbDataAdapter) = databaseFacade.CreateDbDataAdapter(sql, commandType);
Expand Down Expand Up @@ -275,8 +275,12 @@ private static (DbConnection dbConnection, DbCommand dbCommand, DbDataAdapter db
dbConnection = _dbConnection;

// 创建数据适配器并设置查询命令对象
var dbDataAdapter = profiledDbProviderFactory.CreateDataAdapter();
dbDataAdapter.SelectCommand = dbCommand;
// EFCore 5.0 未提供 Sqlite DataAdapter
var dbDataAdapter = DbProvider.IsDatabaseFor(databaseFacade.ProviderName, DbProvider.Sqlite) ? default : profiledDbProviderFactory.CreateDataAdapter();
if (dbDataAdapter != null)
{
dbDataAdapter.SelectCommand = dbCommand;
}

// 返回
return (dbConnection, dbCommand, dbDataAdapter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,17 @@ public static async Task<object> ExecuteScalarAsync(this DatabaseFacade database
/// <returns>DataSet</returns>
public static DataSet DataAdapterFill(this DatabaseFacade databaseFacade, string sql, DbParameter[] parameters = null, CommandType commandType = CommandType.Text)
{
// 处理 Sqlite 不支持 DataSet 问题
if (DbProvider.IsDatabaseFor(databaseFacade.ProviderName, DbProvider.Sqlite))
{
return SqliteDataSetFill(databaseFacade, sql, parameters, commandType);
}

// 获取真实运行 Sql
sql = DbHelpers.ResolveSqlConfiguration(sql);

// 初始化数据库连接对象、数据库命令对象和数据库适配器对象
var (_, dbCommand, dbDataAdapter) = databaseFacade.PrepareDbDbDataAdapter(sql, parameters, commandType);
var (_, dbCommand, dbDataAdapter) = databaseFacade.PrepareDbDataAdapter(sql, parameters, commandType);

// 填充DataSet
using var dataSet = new DataSet();
Expand All @@ -376,11 +382,17 @@ public static DataSet DataAdapterFill(this DatabaseFacade databaseFacade, string
/// <returns>(DataSet dataSet, DbParameter[] dbParameters)</returns>
public static (DataSet dataSet, DbParameter[] dbParameters) DataAdapterFill(this DatabaseFacade databaseFacade, string sql, object model, CommandType commandType = CommandType.Text)
{
// 处理 Sqlite 不支持 DataSet 问题
if (DbProvider.IsDatabaseFor(databaseFacade.ProviderName, DbProvider.Sqlite))
{
return SqliteDataSetFill(databaseFacade, sql, model, commandType);
}

// 获取真实运行 Sql
sql = DbHelpers.ResolveSqlConfiguration(sql);

// 初始化数据库连接对象、数据库命令对象和数据库适配器对象
var (_, dbCommand, dbDataAdapter, dbParameters) = databaseFacade.PrepareDbDbDataAdapter(sql, model, commandType);
var (_, dbCommand, dbDataAdapter, dbParameters) = databaseFacade.PrepareDbDataAdapter(sql, model, commandType);

// 填充DataSet
using var dataSet = new DataSet();
Expand All @@ -403,11 +415,17 @@ public static (DataSet dataSet, DbParameter[] dbParameters) DataAdapterFill(this
/// <returns></returns>
public static async Task<DataSet> DataAdapterFillAsync(this DatabaseFacade databaseFacade, string sql, DbParameter[] parameters = null, CommandType commandType = CommandType.Text, CancellationToken cancellationToken = default)
{
// 处理 Sqlite 不支持 DataSet 问题
if (DbProvider.IsDatabaseFor(databaseFacade.ProviderName, DbProvider.Sqlite))
{
return await SqliteDataSetFillAsync(databaseFacade, sql, parameters, commandType, cancellationToken: cancellationToken);
}

// 获取真实运行 Sql
sql = DbHelpers.ResolveSqlConfiguration(sql);

// 初始化数据库连接对象、数据库命令对象和数据库适配器对象
var (_, dbCommand, dbDataAdapter) = await databaseFacade.PrepareDbDbDataAdapterAsync(sql, parameters, commandType, cancellationToken);
var (_, dbCommand, dbDataAdapter) = await databaseFacade.PrepareDbDataAdapterAsync(sql, parameters, commandType, cancellationToken);

// 填充DataSet
using var dataSet = new DataSet();
Expand All @@ -430,11 +448,17 @@ public static async Task<DataSet> DataAdapterFillAsync(this DatabaseFacade datab
/// <returns>(DataSet dbSet, DbParameter[] dbParameters)</returns>
public static async Task<(DataSet dbSet, DbParameter[] dbParameters)> DataAdapterFillAsync(this DatabaseFacade databaseFacade, string sql, object model, CommandType commandType = CommandType.Text, CancellationToken cancellationToken = default)
{
// 处理 Sqlite 不支持 DataSet 问题
if (DbProvider.IsDatabaseFor(databaseFacade.ProviderName, DbProvider.Sqlite))
{
return await SqliteDataSetFillAsync(databaseFacade, sql, model, commandType, cancellationToken: cancellationToken);
}

// 获取真实运行 Sql
sql = DbHelpers.ResolveSqlConfiguration(sql);

// 初始化数据库连接对象、数据库命令对象和数据库适配器对象
var (_, dbCommand, dbDataAdapter, dbParameters) = await databaseFacade.PrepareDbDbDataAdapterAsync(sql, model, commandType, cancellationToken);
var (_, dbCommand, dbDataAdapter, dbParameters) = await databaseFacade.PrepareDbDataAdapterAsync(sql, model, commandType, cancellationToken);

// 填充DataSet
using var dataSet = new DataSet();
Expand All @@ -445,5 +469,137 @@ public static async Task<DataSet> DataAdapterFillAsync(this DatabaseFacade datab

return (dataSet, dbParameters);
}

/// <summary>
/// Sqlite DataSet Fill
/// </summary>
/// <param name="databaseFacade">ADO.NET 数据库对象</param>
/// <param name="sql">sql 语句</param>
/// <param name="commandType">命令类型</param>
/// <param name="parameters">命令参数</param>
/// <param name="behavior">行为</param>
/// <returns>DataTable</returns>
private static DataSet SqliteDataSetFill(this DatabaseFacade databaseFacade, string sql, DbParameter[] parameters = null, CommandType commandType = CommandType.Text, CommandBehavior behavior = CommandBehavior.Default)
{
// 获取真实运行 Sql
sql = DbHelpers.ResolveSqlConfiguration(sql);

var sqls = sql.Split(";", StringSplitOptions.RemoveEmptyEntries);

// 初始化数据库连接对象和数据库命令对象
var (_, dbCommand) = databaseFacade.PrepareDbCommand(string.Empty, parameters, commandType);

// 执行多个 Sql
var dataset = ExecuteSqlsForSqlite(behavior, sqls, dbCommand);

return dataset;
}

/// <summary>
/// Sqlite DataSet Fill
/// </summary>
/// <param name="databaseFacade">ADO.NET 数据库对象</param>
/// <param name="sql">sql 语句</param>
/// <param name="commandType">命令类型</param>
/// <param name="model">命令模型</param>
/// <param name="behavior">行为</param>
/// <returns>(DataTable dataTable, DbParameter[] dbParameters)</returns>
private static (DataSet dataSet, DbParameter[] dbParameters) SqliteDataSetFill(this DatabaseFacade databaseFacade, string sql, object model, CommandType commandType = CommandType.Text, CommandBehavior behavior = CommandBehavior.Default)
{
// 获取真实运行 Sql
sql = DbHelpers.ResolveSqlConfiguration(sql);

var sqls = sql.Split(";", StringSplitOptions.RemoveEmptyEntries);

// 初始化数据库连接对象和数据库命令对象
var (_, dbCommand, dbParameters) = databaseFacade.PrepareDbCommand(string.Empty, model, commandType);

// 执行多个 Sql
var dataset = ExecuteSqlsForSqlite(behavior, sqls, dbCommand);

return (dataset, dbParameters);
}

/// <summary>
/// Sqlite DataSet Fill
/// </summary>
/// <param name="databaseFacade">ADO.NET 数据库对象</param>
/// <param name="sql">sql 语句</param>
/// <param name="commandType">命令类型</param>
/// <param name="parameters">命令参数</param>
/// <param name="behavior">行为</param>
/// <param name="cancellationToken"></param>
/// <returns>DataTable</returns>
private static async Task<DataSet> SqliteDataSetFillAsync(this DatabaseFacade databaseFacade, string sql, DbParameter[] parameters = null, CommandType commandType = CommandType.Text, CommandBehavior behavior = CommandBehavior.Default, CancellationToken cancellationToken = default)
{
// 获取真实运行 Sql
sql = DbHelpers.ResolveSqlConfiguration(sql);

var sqls = sql.Split(";", StringSplitOptions.RemoveEmptyEntries);

// 初始化数据库连接对象和数据库命令对象
var (_, dbCommand) = await databaseFacade.PrepareDbCommandAsync(string.Empty, parameters, commandType, cancellationToken);

// 执行多个 Sql
var dataset = ExecuteSqlsForSqlite(behavior, sqls, dbCommand);

return dataset;
}

/// <summary>
/// Sqlite DataSet Fill
/// </summary>
/// <param name="databaseFacade">ADO.NET 数据库对象</param>
/// <param name="sql">sql 语句</param>
/// <param name="commandType">命令类型</param>
/// <param name="model">命令模型</param>
/// <param name="behavior">行为</param>
/// <param name="cancellationToken"></param>
/// <returns>(DataTable dataTable, DbParameter[] dbParameters)</returns>
private static async Task<(DataSet dataSet, DbParameter[] dbParameters)> SqliteDataSetFillAsync(this DatabaseFacade databaseFacade, string sql, object model, CommandType commandType = CommandType.Text, CommandBehavior behavior = CommandBehavior.Default, CancellationToken cancellationToken = default)
{
// 获取真实运行 Sql
sql = DbHelpers.ResolveSqlConfiguration(sql);

var sqls = sql.Split(";", StringSplitOptions.RemoveEmptyEntries);

// 初始化数据库连接对象和数据库命令对象
var (_, dbCommand, dbParameters) = await databaseFacade.PrepareDbCommandAsync(string.Empty, model, commandType, cancellationToken);

// 执行多个 Sql
var dataset = ExecuteSqlsForSqlite(behavior, sqls, dbCommand);

return (dataset, dbParameters);
}

/// <summary>
/// 执行 Sqlite 多个 Sql
/// </summary>
/// <param name="behavior"></param>
/// <param name="sqls"></param>
/// <param name="dbCommand"></param>
/// <returns></returns>
private static DataSet ExecuteSqlsForSqlite(CommandBehavior behavior, string[] sqls, DbCommand dbCommand)
{
var dataset = new DataSet();

foreach (var itemSql in sqls)
{
dbCommand.CommandText = itemSql;

// 读取数据
using var dbDataReader = dbCommand.ExecuteReader(behavior);

// 填充到 DataTable
using var dataTable = new DataTable();
dataTable.Load(dbDataReader);

dataset.Tables.Add(dataTable);
}

// 清空命令参数
dbCommand.Parameters.Clear();
return dataset;
}
}
}
Loading

0 comments on commit b3d5b80

Please sign in to comment.