我有一个简单的 Oracle 存储过程,它传入三个参数,并有一个输出参数:
CREATE OR REPLACE PROCEDURE RA.RA_REGISTERASSET
(
INPROJECTNAME IN VARCHAR2
,INCOUNTRYCODE IN VARCHAR2
,INLOCATION IN VARCHAR2
,OUTASSETREGISTERED OUT VARCHAR2
)
AS
BEGIN
SELECT
INPROJECTNAME || ', ' || INLOCATION || ', ' || INCOUNTRYCODE
INTO
OUTASSETREGISTERED
FROM
DUAL;
END RA_REGISTERASSET;
我正在尝试使用 Entity Framework 6.1 来取回该OutAssetRegistered
值,但是,在调用后我得到一个空值,SqlQuery
无一例外:
public class CmdRegisterAssetDto
{
public string inProjectName { get; set; }
public string inCountryCode { get; set; }
public string inLocation { get; set; }
public string OutAssetRegistered { get; set; }
}
//------------------------------------------------ ------------
string projectName = "EXCO";
string location = "ANYWHERE";
string countryCode = "XX";
using (var ctx = new RAContext())
{
var projectNameParam = new OracleParameter("inProjectName", OracleDbType.Varchar2, projectName, ParameterDirection.Input);
var countryCodeParam = new OracleParameter("inCountryCode", OracleDbType.Varchar2, countryCode, ParameterDirection.Input);
var locationParam = new OracleParameter("inLocation", OracleDbType.Varchar2, location, ParameterDirection.Input);
var assetRegisteredParam = new OracleParameter("OutAssetRegistered", OracleDbType.Varchar2, ParameterDirection.Output);
var sql = "BEGIN RA.RA_RegisterAsset(:inProjectName, :inCountryCode, :inLocation, :OutAssetRegistered); END;";
var query = ctx.Database.SqlQuery<CmdRegisterAssetDto>(sql, projectNameParam, countryCodeParam, locationParam, assetRegisteredParam
);
assetRegistered = (string)assetRegisteredParam.Value;
}
我一直在努力让这个工作无济于事,检查了不同的博客,所有其他的 crud 操作都有效,谁能帮助并指导我哪里出错了?