1、为AssemblyAutoRegisterOptions.SmartSqlAlias设置默认值;2、仓储接口注册时,获取ISqlMapper实例都通过IServiceProvider.EnsureSmartSql方法获取 #216
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
在注册多数据库实例情况下,如果没有使用UseAlias()方法设置Alias时,会默认使用DEFAULT_ALIAS = "SmartSql"。但是在仓储接口实例化时,通过
sp.GetRequiredService<ISqlMapper>()
方法获取ISqlMapper
实例就由后注册的SmartSqlDIBuilder
实例提供。因此将
sp.GetRequiredService<ISqlMapper>()
改成统一使用SmartSqlBuilder EnsureSmartSql(this IServiceProvider sp, string alias = SmartSqlBuilder.DEFAULT_ALIAS)
方法获取ISqlMapper
实例,改后的代码即:为类型
AssemblyAutoRegisterOptions
的属性SmartSqlAlias
设置默认值,也是为了实现第一个SmartSqlDIBuilder
实例注册时没有单独指定Alias的时候,也能够正确获取仓储接口实例,与上面的改动都是相同的目的。