Skip to content

Commit

Permalink
add support TypeHandler for CommandType.StoredProcedure
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahoo-Wang committed Dec 18, 2019
1 parent 3de5e91 commit 3f0ac5b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build/version.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<VersionMajor>4</VersionMajor>
<VersionMinor>1</VersionMinor>
<VersionPatch>44</VersionPatch>
<VersionPatch>45</VersionPatch>
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
</PropertyGroup>
</Project>
6 changes: 1 addition & 5 deletions src/SmartSql.Test.Unit/Cryptos/RSACryptoTest.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using SmartSql.TypeHandler.Crypto;
using Xunit;

namespace SmartSql.Test.Unit.Cryptos
{
public class RSACryptoTest
{
[Fact]
// [Fact]
public void Test()
{
using (var rsaCrypto = new RSACrypto())
Expand Down
4 changes: 1 addition & 3 deletions src/SmartSql/Data/SqlParameter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using SmartSql.TypeHandlers;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Text;

namespace SmartSql.Data
{
Expand Down Expand Up @@ -51,7 +49,7 @@ public object Value
public Type ParameterType { get; set; }
public Action<SqlParameter> OnSetSourceParameter { get; set; }

public DbParameter SourceParameter
internal DbParameter SourceParameter
{
get => _sourceParameter;
set
Expand Down
10 changes: 6 additions & 4 deletions src/SmartSql/Middlewares/PrepareStatementMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ private void BuildDbParameters(AbstractRequestContext reqConetxt)
foreach (var sqlParameter in reqConetxt.Parameters.Values)
{
var sourceParam = _dbProviderFactory.CreateParameter();
InitSourceDbParameter(sourceParam, sqlParameter);
sourceParam.ParameterName = sqlParameter.Name;
sourceParam.Value = sqlParameter.Value;
sqlParameter.TypeHandler?.SetParameter(sourceParam, sqlParameter.Value);
sqlParameter.SourceParameter = sourceParam;
InitSourceDbParameter(sourceParam, sqlParameter);
}
}
else
Expand All @@ -62,14 +63,15 @@ private void BuildDbParameters(AbstractRequestContext reqConetxt)
return nameWithPrefix;
}
ITypeHandler typeHandler = (reqConetxt.ParameterMap?.GetParameter(paramName)?.Handler ?? sqlParameter.TypeHandler) ??
_typeHandlerFactory.GetTypeHandler(sqlParameter.ParameterType);
ITypeHandler typeHandler =
(reqConetxt.ParameterMap?.GetParameter(paramName)?.Handler ?? sqlParameter.TypeHandler) ??
_typeHandlerFactory.GetTypeHandler(sqlParameter.ParameterType);
var sourceParam = _dbProviderFactory.CreateParameter();
InitSourceDbParameter(sourceParam, sqlParameter);
sourceParam.ParameterName = sqlParameter.Name;
typeHandler.SetParameter(sourceParam, sqlParameter.Value);
sqlParameter.SourceParameter = sourceParam;
InitSourceDbParameter(sourceParam, sqlParameter);
if (sqlParameter.Name != paramName)
{
return
Expand Down

0 comments on commit 3f0ac5b

Please sign in to comment.