alter procedure [dbo].[XXX]
(
@vendorworksationID uniqueidentifier ,
@sdate date,
@edate date,
@total int out
)
begin
select @total = COUNT(*)
from AdvertisedCampaignHistory a
where
CAST(a.CreationDate AS DATE) BETWEEN CAST(@sdate as DATE) AND CAST(@edate as DATE)
and a.CampaignID in (select cc.BCampaignID
from BeaconCampaign cc, VendorWorkStation vw
where cc.VendorWorkStationID = vw.VendorWorkStationID
and VendorID = @vendorworksationID)
return @total
end
上面的代码显示了从SQL Server返回整数值的存储过程
ObjectParameter Output = new ObjectParameter("total", typeof(Int32));
var resBC = this.Context.getTotalSentBeaconCampaign(VendorWorkstationID, sdate,edate,Output).FirstOrDefault();
上面的代码显示了我如何传递参数并在C#端检索值
运行代码时出现以下错误
商店数据提供商返回的数据阅读器没有 足够的列用于请求的查询。
导致此错误的可能原因是什么?
答案 0 :(得分:0)
实体框架无法支持存储过程返回标量值。要使其与Entity Framework一起使用,您需要使用"选择"而不是"返回"返回值。
更多参考:http://www.devtoolshed.com/using-stored-procedures-entity-framework-scalar-return-values