Added suport for DynamicColumn in DynamicProcedureInvoker
This commit is contained in:
@@ -685,6 +685,7 @@ namespace DynamORM
|
||||
/// <summary>Initializes a new instance of the <see cref="DynamicColumn" /> class.</summary>
|
||||
public DynamicColumn()
|
||||
{
|
||||
ParameterDirection = ParameterDirection.Input;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="DynamicColumn" /> class.</summary>
|
||||
@@ -726,6 +727,9 @@ namespace DynamORM
|
||||
/// <summary>Gets or sets order direction.</summary>
|
||||
public SortOrder Order { get; set; }
|
||||
|
||||
/// <summary>Gets or sets parameter direction when used in procedure invocation.</summary>
|
||||
public ParameterDirection ParameterDirection { get; set; }
|
||||
|
||||
/// <summary>Gets or sets value for parameters.</summary>
|
||||
public object Value { get; set; }
|
||||
|
||||
@@ -5371,6 +5375,37 @@ namespace DynamORM
|
||||
cmd.AddParameters(_db, (DynamicExpando)arg);
|
||||
else if (arg is ExpandoObject)
|
||||
cmd.AddParameters(_db, (ExpandoObject)arg);
|
||||
else if (arg is DynamicColumn)
|
||||
{
|
||||
var dcv = (DynamicColumn)arg;
|
||||
|
||||
string paramName = dcv.Alias ?? dcv.ColumnName ??
|
||||
(dcv.Schema.HasValue ? dcv.Schema.Value.Name : null) ??
|
||||
(info.ArgumentNames.Count > i ? info.ArgumentNames[i] : i.ToString());
|
||||
|
||||
bool isOut = dcv.ParameterDirection == ParameterDirection.Output ||
|
||||
dcv.ParameterDirection == ParameterDirection.ReturnValue;
|
||||
|
||||
if (isOut || dcv.ParameterDirection == ParameterDirection.InputOutput)
|
||||
{
|
||||
if (retParams == null)
|
||||
retParams = new Dictionary<string, int>();
|
||||
retParams.Add(paramName, cmd.Parameters.Count);
|
||||
}
|
||||
|
||||
if (dcv.Schema != null)
|
||||
{
|
||||
var ds = dcv.Schema.Value;
|
||||
cmd.AddParameter(
|
||||
_db.GetParameterName(paramName), dcv.ParameterDirection,
|
||||
ds.Type, ds.Size, ds.Precision, ds.Scale,
|
||||
isOut ? DBNull.Value : arg);
|
||||
}
|
||||
else
|
||||
cmd.AddParameter(
|
||||
_db.GetParameterName(paramName), dcv.ParameterDirection,
|
||||
arg == null ? DbType.String : arg.GetType().ToDbType(), 0, isOut ? DBNull.Value : arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (info.ArgumentNames.Count > i && !string.IsNullOrEmpty(info.ArgumentNames[i]))
|
||||
@@ -5473,7 +5508,7 @@ namespace DynamORM
|
||||
|
||||
using (IDataReader rdr = cmd.ExecuteReader())
|
||||
if (rdr.Read())
|
||||
mainResult = (rdr.ToDynamic() as object).Map(types[0]);
|
||||
mainResult = (rdr.RowToDynamic() as object).Map(types[0]);
|
||||
else
|
||||
mainResult = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user