-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support DbCommandCreated event for CommandExecuter
fix #89
- Loading branch information
Showing
10 changed files
with
116 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\SmartSql\SmartSql.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.18.3" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Microsoft.Extensions.Logging; | ||
using Oracle.ManagedDataAccess.Client; | ||
using SmartSql.Command; | ||
using SmartSql.Exceptions; | ||
|
||
namespace SmartSql | ||
{ | ||
public static class SmartSqlBuilderExtensions | ||
{ | ||
public static SmartSqlBuilder UseOracleCommandExecuter(this SmartSqlBuilder smartSqlBuilder) | ||
{ | ||
return UseOracleCommandExecuter(smartSqlBuilder, smartSqlBuilder.LoggerFactory); | ||
} | ||
public static SmartSqlBuilder UseOracleCommandExecuter(this SmartSqlBuilder smartSqlBuilder, | ||
ILoggerFactory loggerFactory) | ||
{ | ||
var cmdExe = new CommandExecuter(loggerFactory.CreateLogger<CommandExecuter>()); | ||
cmdExe.DbCommandCreated += OnDbCommandCreated; | ||
return smartSqlBuilder; | ||
} | ||
|
||
private static void OnDbCommandCreated(object cmdExe, DbCommandCreatedEventArgs eventArgs) | ||
{ | ||
var oracleCommand = eventArgs.DbCommand as OracleCommand; | ||
if (oracleCommand == null) | ||
{ | ||
throw new SmartSqlException("The ADO.NET Driver is not [Oracle.ManagedDataAccess.Core]."); | ||
} | ||
|
||
oracleCommand.BindByName = true; | ||
oracleCommand.InitialLONGFetchSize = -1; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters