我有以下存储过程:
ALTER PROCEDURE [dbo].[spRptFundsTransferSchoolProfileSelect]
(
@SessionID int ,
@DateRangeStart DateTime,
@DateRangeEnd DateTime
)
AS
BEGIN
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
--set @SessionID = 1175
SELECT tss.school_id,
ts.school_code,
tss.id,
ts.school_name,
ta.address,
ta.city,
ta.zip,
FROM T_School ts
Execute [dbo].[spRptFundsTransferPaymentSummarySelect] @SessionID ,
@DateRangeStart ,
@DateRangeEnd
END
以及关于返回输出的以下模型:
namespace FundTr.de
{
public class FundTrans : ModelBase
{
public string school_name { get; set; }
public string school_code { get; set; }
public int school_id { get; set; }
public long id { get; set; }
public string address { get; set; }
public string city { get; set; }
public string zip { get; set; }
public string Date_Added { get; set; }//from dbo.spRptFundsTransferPaymentSummarySelect procedure
}
}
contolller:
public ActionResult GetFundTransferReportTemplate(DateTime DateRangeStart, DateTime DateRangeEnd)
{
return SmartJson(ReportService.GetFundTransferReportTemplate(DateRangeStart, DateRangeEnd));
}
服务:
public static FundTransferReportTemplate GetFundTransferReportTemplate(DateTime DateRangeStart, DateTime DateRangeEnd)
{
long SessionID = 1175;// SmartState.session.schoolSession.SessionId;
var repo = GetRepository<FundTransferReportTemplate>();
var da = repo.GetSingleObject("spRptFundsTransferSchoolProfileSelect", new { DateRangeStart, DateRangeEnd, SessionID });
return da;
}
当我点击控制器时,除了最后一个&#34; Date_Added&#34;(来自程序dbo.spRptFundsTransferPaymentSummarySelect的此字段),我得到所有值。 我的意思是说我没有获得dbo.spRptFundsTransferPaymentSummarySelect的输出值。我可以得到 访问在主程序中执行的程序的输出值?
答案 0 :(得分:0)
SP从上到下执行,从某种意义上说,它将执行SELECT
语句,然后执行SP spRptFundsTransferPaymentSummarySelect 。假设SP spRptFundsTransferPaymentSummarySelect 返回单个值,即 date_added
您需要先调用 spRptFundsTransferPaymentSummarySelect 并将值存储在变量@Date_Added
中,然后在SELECT
语句中使用它。
ALTER PROCEDURE [dbo].[spRptFundsTransferSchoolProfileSelect]
(
@SessionID int,
@DateRangeStart DateTime,
@DateRangeEnd DateTime
)
AS
BEGIN
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
DECLARE @Date_Added DateTime
Execute @Date_Added = [dbo].[spRptFundsTransferPaymentSummarySelect] @SessionID,
@DateRangeStart,
@DateRangeEnd
--set @SessionID = 1175
SELECT tss.school_id,
ts.school_code,
ts.id,
ts.school_name,
ta.address,
ta.city,
ta.zip,
@Date_Added AS Date_Added
FROM T_School ts
END