首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

select count(*) from record 存储过程在linq中的使用有关问题

2012-02-13 
select count(*) from record 存储过程在linq中的使用问题我写了个存储过程select count(*) from record,

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

热点排行