SqlHelperExecuteScalarT(ExecuteType, String, Object) Method
執行指令並取得第1筆資料的第1個欄位值
帶入參數名稱需與查詢式中參數名稱大小寫一致;『@』符號僅查詢式中參數名稱需前輟
using (SqlHelper sqlHelper = new SqlHelper("SqlServer"))
{
DatabaseResult<Guid> result = sqlHelper.ExecuteScalar<Guid>(ExecuteType.Text, sqlHelper.GetQueryString<Employee>() + " Where IneffectiveDate Is Null Or IneffectiveDate >= @IneffectiveDate", new { IneffectiveDate = DateTime.Now });
if (result.IsSuccess) {
Guid employeeId = result.Result;
//Do something
} else {
Exception exception = result.Exception;
//Error handling
}
}
| Date | Version | Description |
|---|
| 2020/02/07 | 1.0.0.0 | 初版 |
| 2020/02/19 | 1.0.0.1 | 調整回傳格式包含執行成功與否以及異常訊息 |
| 2020/09/01 | 1.0.18.0 | 增加Log明細 |
| 2020/09/25 | 1.0.19.0 | 調整快取及交易機制 |
| 2025/09/19 | 25.0.0.0 | 彙整2025年度初版 |