SqlHelperQueryProcedureFirstOrDefaultT(String, Object) Method
執行預存程序並取得第1筆回傳結果,若無資料回傳預設值
帶入參數名稱需與查詢式中參數名稱大小寫一致;『@』符號僅查詢式中參數名稱需前輟
using (SqlHelper sqlHelper = new SqlHelper("SqlServer"))
{
DatabaseResult<TableInfo> result = sqlHelper.QueryProcedureFirstOrDefault<TableInfo>("sp_tables", new { table_name = "Employee", table_owner = "dbo", table_qualifier = "eBizprise" });
if (result.IsSuccess) {
TableInfo tableInfo = result.Result;
//Do something
} else {
Exception exception = result.Exception;
//Error handling
}
}
// 資料表資訊
public class TableInfo
{
// 資料庫
public string TABLE_QUALIFIER { get; set; }
// 擁有者
public string TABLE_OWNER { get; set; }
// 資料表名稱
public string TABLE_NAME { get; set; }
// 資料表類型
public string TABLE_TYPE { get; set; }
}
| Date | Version | Description |
|---|
| 2020/02/07 | 1.0.0.0 | 初版 |
| 2020/02/19 | 1.0.0.1 | 調整回傳格式包含執行成功與否以及異常訊息 |
| 2025/09/19 | 25.0.0.0 | 彙整2025年度初版 |