public async Task <ThirdPartySystemTokenRecord> QueryByID(string userKey, Guid id) { var storeInfo = await GetDBAllStoreInfo(userKey, _thirdPartySystemTokenRecordHashGroupName); ThirdPartySystemTokenRecord result = null; await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, false, false, storeInfo[0], async (conn, transaction) => { SqlTransaction sqlTran = null; if (transaction != null) { sqlTran = (SqlTransaction)transaction; } await using (SqlCommand command = new SqlCommand() { Connection = (SqlConnection)conn, CommandType = CommandType.Text, Transaction = sqlTran, }) { SqlParameter parameter; command.CommandText = string.Format(@"SELECT {0} FROM [dbo].[{1}] WHERE id=@id;", StoreHelper.GetThirdPartySystemTokenRecordStoreSelectFields(string.Empty), storeInfo[1]); parameter = new SqlParameter("@id", SqlDbType.UniqueIdentifier) { Value = id }; command.Parameters.Add(parameter); await command.PrepareAsync(); SqlDataReader reader = null; await using (reader = await command.ExecuteReaderAsync()) { if (await reader.ReadAsync()) { result = new ThirdPartySystemTokenRecord(); StoreHelper.SetThirdPartySystemTokenRecordSelectFields(result, reader, string.Empty); result.SystemLoginEndpoint = await _systemLoginEndpointStore.QueryById(result.SystemLoginEndpointID); result.AuthorizationEndpoint = await _authorizationEndpointStore.QueryById(result.AuthorizationEndpointID); if (result.AuthorizationEndpoint == null || result.SystemLoginEndpoint == null) { result = null; } } await reader.CloseAsync(); } } }); return(result); }
public async Task <AuthorizationEndpoint> QueryById(Guid id) { return(await _authorizationEndpointStore.QueryById(id)); }