private async Task ParseExecuteScalarDbValueAsync <TResult>(ExecutionContext executionContext) { var singleResult = executionContext.Result as SingleResultContext <TResult>; var dbResult = await _commandExecuter.ExecuteScalarAsync(executionContext); SetResultData(dbResult, singleResult); }
private async Task ParseExecuteScalarDbValueAsync <TResult>(ExecutionContext executionContext) { var singleResult = executionContext.Result as SingleResultContext <TResult>; var dbResult = await _commandExecuter.ExecuteScalarAsync(executionContext); if (dbResult == null || dbResult == DBNull.Value) { singleResult.SetData(default(TResult)); } else { var convertType = singleResult.ResultType; convertType = Nullable.GetUnderlyingType(convertType) ?? convertType; if (convertType.IsEnum) { singleResult.SetData(Enum.ToObject(convertType, dbResult)); } else { singleResult.SetData(Convert.ChangeType(dbResult, convertType)); } } }