簡體   English   中英

EF6存儲過程-output方向參數

[英]EF6 stored procedure - output direction parameter

使用 output 方向參數運行 EF6 存儲過程的正確方法是什么?

List<MySqlParameter> parms = new()
{
   new MySqlParameter { ParameterName = "@FilterJson", Value = JsonConvert.SerializeObject(input) },
   new MySqlParameter { ParameterName = "@OutputJson", Direction = System.Data.ParameterDirection.Output }
};

var response = ReportingDetail.FromSqlRaw(
   @"CALL p_detail_get(@FilterJson, @OutputJson)",
   parms.ToArray()
);

此代碼引發錯誤:

MySqlConnector.MySqlException:“當 CommandType 為文本時,僅支持 ParameterDirection.Input(參數名稱:@OutputJson)”

預期 output 是 JSON,類似於: {"rows_count": 7, "actual_page": 1, "pages_count": 1}

問題不在於連接,沒有 output 方向的其他程序工作正常。 定義 @OutputJson 的類型並不能解決問題 - MySqlDbType = MySqlDbType.JSONDbType = System.Data.DbType.Object

感謝您的任何幫助

根據MySqlConnector的討論,不可能通過它返回output方向參數。 你可以嘗試寫 ADO.NET 代碼來省略這個限制。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM