Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/Dapper.Oracle/OracleDynamicParameters.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//// Based on Gist found here: https://gist.github.com/vijaysg/3096151
//// Based on Gist found here: https://gist.github.com/vijaysg/3096151

using System;
using System.Collections;
Expand Down Expand Up @@ -109,6 +109,7 @@ public void AddDynamicParams(dynamic param)
/// <param name="sourceColumn"></param>
/// <param name="sourceVersion"></param>
/// <param name="collectionType"></param>
/// <param name="maskValueWhenLogging">a flag that this param contains sensitive data and it must be masked in case of logging values</param>
public void Add(
string name,
object value = null,
Expand All @@ -121,7 +122,8 @@ public void Add(
string sourceColumn = null,
DataRowVersion? sourceVersion = null,
OracleMappingCollectionType? collectionType = null,
int[] arrayBindSize = null)
int[] arrayBindSize = null,
bool maskValueWhenLogging = false)
{
Parameters[Clean(name)] = new OracleParameterInfo()
{
Expand All @@ -136,7 +138,8 @@ public void Add(
SourceColumn = sourceColumn,
SourceVersion = sourceVersion ?? DataRowVersion.Current,
CollectionType = collectionType ?? OracleMappingCollectionType.None,
ArrayBindSize = arrayBindSize
ArrayBindSize = arrayBindSize,
MaskValueWhenLogging = maskValueWhenLogging
};
}

Expand Down Expand Up @@ -167,7 +170,7 @@ public T Get<T>(string name)
}
return default(T);
}

return OracleValueConverter.Convert<T>(val);
}

Expand Down Expand Up @@ -239,10 +242,10 @@ protected virtual void AddParameters(IDbCommand command, SqlMapper.Identity iden
}

OracleMethodHelper.SetOracleParameters(p, param);

p.Direction = param.ParameterDirection;
var val = param.Value;

var val = param.Value;

if (val != null && OracleTypeMapper.HasTypeHandler(val.GetType(), out var handler))
{
Expand All @@ -251,7 +254,7 @@ protected virtual void AddParameters(IDbCommand command, SqlMapper.Identity iden
else
{
p.Value = val ?? DBNull.Value;

var s = val as string;
if (s?.Length <= 4000)
{
Expand All @@ -262,8 +265,8 @@ protected virtual void AddParameters(IDbCommand command, SqlMapper.Identity iden
{
p.Size = param.Size.Value;
}
}
}

if (add)
{
command.Parameters.Add(p);
Expand Down Expand Up @@ -320,6 +323,8 @@ public class OracleParameterInfo
public OracleParameterMappingStatus Status { get; set; }

public IDbDataParameter AttachedParam { get; set; }

public bool MaskValueWhenLogging { get; set; }
}

/// <summary>
Expand All @@ -328,4 +333,4 @@ public class OracleParameterInfo
/// <returns></returns>
public IEnumerator GetEnumerator() => Parameters.GetEnumerator();
}
}
}