我有这个存储过程,用于从 3 个表中获取 Amount 的总和。
问题是我正在使用 Linq to Sql,当我将此过程放在我的 .dbml 文件中时,它有一个 ISingleResult(GetSurplusDataForConsolidationReportResult) 并且我无法得到我想要的总和。
我收到一个空的 ReceivablesSurplus 清单。
有任何想法吗?
ALTER PROCEDURE [dbo].[GetSurplusDataForConsolidationReport]
@ID INT
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT SUM(RB.[Amount])
FROM [DBO].[ReceivablesSurplus] RB
WHERE RB.[Cycle] = @ID
SELECT SUM(DL.[Amount])
FROM [DBO].[DilutionsSurplus] DL
WHERE DL.[Cycle] = @ID
SELECT SUM(AC.[Amount])
FROM [DBO].[AccountablesSurplus] AC
WHERE AC.[Cycle] = @ID
END
这是我的 .dbml 代码
[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.GetSurplusDataForConsolidationReport")]
public ISingleResult<GetSurplusDataForConsolidationReportResult> GetSurplusDataForConsolidationReport([global::System.Data.Linq.Mapping.ParameterAttribute(Name="ID", DbType="Int")] System.Nullable<int> iD)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), iD);
return ((ISingleResult<GetSurplusDataForConsolidationReportResult>)(result.ReturnValue));
}