SqlHelperQueryFirstT(ExecuteType, String, Object) Method

查詢第1筆資料

Definition

Namespace: eBizprise.Framework
Assembly: eBizprise.Framework.Database.SqlHelper (in eBizprise.Framework.Database.SqlHelper.dll) Version: 25.0.2.0+adf38c4ccb2bf98d8ad258a6278302b5e05a94ed
C#
public DatabaseResult<T> QueryFirst<T>(
	ExecuteType executeType,
	string statement,
	Object parameter
)

Parameters

executeType  ExecuteType
執行類型
statement  String
查詢指令
parameter  Object
參數

Type Parameters

T
回傳類型

Return Value

DatabaseResultT
DatabaseResult<T>

Implements

IDatabaseHelperQueryFirstT(ExecuteType, String, Object)

Remarks

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

Example

C#
using (SqlHelper sqlHelper = new SqlHelper("SqlServer"))
{
    DatabaseResult<Employee> result = sqlHelper.QueryFirst<Employee>(ExecuteType.Text, sqlHelper.GetQueryString<Employee>() + " Where IneffectiveDate Is Null Or IneffectiveDate >= @IneffectiveDate", new { IneffectiveDate = DateTime.Now });

    if (result.IsSuccess) {
        Employee employee = result.Result;

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

        //Error handling
    }
}

Revision History

DateVersionDescription
2020/02/071.0.0.0初版
2020/02/191.0.0.1調整回傳格式包含執行成功與否以及異常訊息
2020/09/011.0.18.0增加Log明細
2020/09/251.0.19.0調整快取及交易機制
2025/05/212.2.3.0調整SqlHelper增加擴充屬性處理
2025/09/1925.0.0.0彙整2025年度初版

See Also