使用Linq调用传递单个字符串的存储过程,存储过程返回包含字符串和int的数据集行。
代码:
PESQLDataContext pe = new PESQLDataContext(strConnStr);
pe.ObjectTrackingEnabled = false;
gvUnitsPassed.DataSource = pe.PassedInspection(Line);
gvUnitsPassed.DataBind();
pe.dispose();
当代码运行时,会在下面调用异常: 在IExecuteResult result =语句中抛出异常: 附件是designer.cs文件中的结果类。
[Function(Name = "dbo.PassedInspection")]
public ISingleResult<PassedInspectionResult> PassedInspection([Parameter(Name = "Model", DbType = "VarChar(4)")] string model)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), model);
return ((ISingleResult<PassedInspectionResult>)(result.ReturnValue));
}
public partial class PassedInspectionResult
{
private string _Date;
private int _Passed;
public PassedInspectionResult()
{
}
[Column(Storage = "_Date", DbType = "string NULL")]
public string Date
{
get
{
return this._Date;
}
set
{
if ((this._Date != value))
{
this._Date = value;
}
}
}
[Column(Storage = "_Passed", DbType = "Int NULL")]
public int Passed
{
get
{
return this._Passed;
}
set
{
if ((this._Passed != value))
{
this._Passed = value;
}
}
}
}
}
我有其他类似参数的存储过程,运行得很好。
由于
答案 0 :(得分:7)
我很确定这就是导致问题的原因:
[Column(Storage = "_Date", DbType = "string NULL")]
具体是“字符串”位。它应该是字段在存储过程中定义的数据类型。例如varchar(...),ntext等。