c# - 将 UDT 传递给存储过程时出现“值不在预期范围内”
问题描述
这是我到 Oracle 中 UDT 的类映射(非常简单):
[OracleCustomTypeMapping("PORTAL_OPS.SHAPEUDT")]
public class Shape : IOracleCustomType, IOracleCustomTypeFactory
{
[OracleObjectMapping("SIDES")]
public Int32 Sides { get; set; }
public string UdtTypeName
{
get
{
Attribute attr = Attribute.GetCustomAttribute(this.GetType()
, typeof(OracleCustomTypeMappingAttribute));
return (attr != null) ?
((OracleCustomTypeMappingAttribute)attr).UdtTypeName
:
String.Empty;
}
}
public void FromCustomObject(OracleConnection con, IntPtr pUdt)
{
OracleUdt.SetValue(con, pUdt, "SIDES", Sides);
}
public void ToCustomObject(OracleConnection con, IntPtr pUdt)
{
Sides = (int)OracleUdt.GetValue(con, pUdt,"SIDES");
}
public IOracleCustomType CreateObject()
{
return new Shape();
}
}
调用存储过程:
if (Command.Connection.State == ConnectionState.Closed)
{
Command.Connection.Open();
}
// setting up the parameter
OracleParameter param = new OracleParameter();
param.Direction = ParameterDirection.Input;
param.UdtTypeName = udt.UdtTypeName;
param.DbType = DbType.Object;
param.OracleDbType = OracleDbType.Object;
param.Value = udt;
Command.CommandText = "PORTAL_OPS.PROC_CREATE_SHAPE";
Command.CommandType = CommandType.StoredProcedure;
Command.Parameters.Add(param);
Command.ExecuteNonQuery();
实例化:
Shape shape = new Shape();
shape.sides = 4;
//invoking the stored procedure call (see code above)
我无法弄清楚为什么我不断收到“价值不在预期范围内”。整个周末都在看这个……运气不好。任何帮助是极大的赞赏。
解决方案
推荐阅读
- python - 如何在 Python 中设置 SimpleITK `ConnectedThreshold` 过滤器的连接性?
- c++ - 在 extern "C" 中包含 cstring 会返回冲突类型错误
- javascript - 如何从 localstorage 在 bingmaps 中添加多边形
- unit-testing - 如何对我的单元测试所做的事情进行“花式”报告
- oracle-adf - 如何在更改选择值时显示/隐藏文本框字段
- powershell - Set-Mailbox Exchange Online cmdlet 无法识别 -CustomAttribute1 参数
- javascript - 如何将字符串二进制数据转换为 AudioBuffer?
- flutter - Flutter Navigation 2 - 在激活时重新加载数据
- mailgun - 无法访问 Mailgun 退订网址
- html - 伪元素块链接问题