select count(*) from record 存储过程在linq中的使用问题
我写了个存储过程
select count(*) from record,然后拖到dbml实现。
自动生成代码如下:
[Function(Name="dbo.GetTotalPageByCategory")]
public ISingleResult<GetTotalPageByCategory_个结果> GetTotalPageByCategory([Parameter(DbType="Int")] System.Nullable<int> category)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), category);
return ((ISingleResult<GetTotalPageByCategory_个结果>)(result.ReturnValue));
}
返回的是一个对象。实际上我想获取的是记录数,即一个int数值。应该怎么处理?
------解决方案--------------------
Hi lgj88lj99:
You can change the code like this:
[Function(Name="dbo.GetTotalPageByCategory")]
public int GetTotalPageByCategory([Parameter(DbType="Int")] System.Nullable<int> category)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), category);
return (int)(result.ReturnValue));
}
Read This link:
http://developer.51cto.com/art/200909/150606.htm