CRUDServiceBaseTEntity, TKey, TInput, TFilterRawExecuteInsertAsync Method

执行插入实体 Insert 语句的方法。

Definition

Namespace: QuickAdmin.Service.CRUD
Assembly: QuickAdmin.Net (in QuickAdmin.Net.dll) Version: 2.0.13
C#
protected virtual Task<IServiceResult> RawExecuteInsertAsync(
	TInput input,
	TEntity entity,
	CancellationToken cancellationToken
)

Parameters

input  TInput
实体输入 DTO。
entity  TEntity
要插入的实体。
cancellationToken  CancellationToken
用于取消操作的令牌。

Return Value

TaskIServiceResult
服务调用结果。

Remarks

即具体执行插入操作的方法,供 AddAsync(TInput, CancellationToken) 方法调用,若需要事务,请在派生类重写。

基类此方法内:
对于 IEntityWithAutoIdKey 类型实体以及 IEntityWithIdKey<int> 类型且标注了主键 IsIdentity=true 的实体, 执行 ExecuteIdentity() 并将返回值赋予实体 Id 属性。
对于其它类型实体,执行 ExecuteAffrows()

See Also