SqlHelperUpdateT(ICollectionT) Method

更新

Definition

Namespace: eBizprise.Framework
Assembly: eBizprise.Framework.Database.SqlHelper (in eBizprise.Framework.Database.SqlHelper.dll) Version: 25.0.2.0+adf38c4ccb2bf98d8ad258a6278302b5e05a94ed
C#
public DatabaseResult<int> Update<T>(
	ICollection<T> updateObjects
)

Parameters

updateObjects  ICollectionT
更新物件

Type Parameters

T
物件類型

Return Value

DatabaseResultInt32
DatabaseResult<int>

Implements

IDatabaseHelperUpdateT(ICollectionT)

Remarks

更新時主要依據主鍵進行更新

Example

C#
using (SqlHelper sqlHelper = new SqlHelper("SqlServer"))
{
    List<Employee> employees = new List<Employee>();
    employees.Add(new Employee() { Account = "Test1", EmployeeId = Guid.NewGuid(), EmployeeNo = "0001", EffectiveDate = DateTime.Now });
    employees.Add(new Employee() { Account = "Test2", EmployeeId = Guid.NewGuid(), EmployeeNo = "0002", EffectiveDate = DateTime.Now });
    employees.Add(new Employee() { Account = "Test3", EmployeeId = Guid.NewGuid(), EmployeeNo = "0003", EffectiveDate = DateTime.Now });

    DatabaseResult<int> result = sqlHelper.Update<Employee>((ICollection)emploees);

    if (result.IsSuccess) {
        int effectRow = 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調整回傳格式包含執行成功與否以及異常訊息

See Also