SqlHelperExecuteAsync(String) Method

異步執行指令並取得影響筆數

Definition

Namespace: eBizprise.Framework
Assembly: eBizprise.Framework.Database.SqlHelper (in eBizprise.Framework.Database.SqlHelper.dll) Version: 25.0.2.0+adf38c4ccb2bf98d8ad258a6278302b5e05a94ed
C#
public Task<DatabaseResult<int>> ExecuteAsync(
	string statement
)

Parameters

statement  String
查詢指令

Return Value

TaskDatabaseResultInt32
DatabaseResult<int>

Remarks

帶入參數名稱需與查詢式中參數名稱大小寫一致;『@』符號僅查詢式中參數名稱需前輟

Example

C#
using (SqlHelper sqlHelper = new SqlHelper("SqlServer"))
{
    DatabaseResult<int> result = sqlHelper.Execute("Delete From Employee Where IneffectiveDate Is Not Null And IneffectiveDate <= GetDate()");

    if (result.IsSuccess) {
        int effectRow = result.Result;

        //Do something
    } else {
        Exception exception = result.Exception;

        //Error handling
    }
}

Revision History

DateVersionDescription
2020/09/281.0.21.0增加異步處理機制
2025/09/1925.0.0.0彙整2025年度初版

See Also