public async Task <TransactionSelectResult> SelectAsync(TransactionSelectArgs args) { TransactionSelectResult logicResult = new TransactionSelectResult(); try { Expression <Func <Transaction, bool> > predicate = CreatePredicate(args); TransactionDTO[] results = await _context.Set <Transaction>().Where(predicate) .Select(x => new TransactionDTO { TransactionId = x.TransactionId, TransactionCode = x.TransactionCode, TransactionName = x.TransactionName, CreditAccountId = x.CreditAccountId, DebitAccountName = x.DebitAccount.AccountName, CreditAccountName = x.CreditAccount.AccountName, DebitAccountId = x.DebitAccountId, TransactionAmount = x.TransactionAmount, IssuedTime = TimeUnit.FromTimeCode(x.IssuedTimeCode) }) .AsNoTracking() .ToArrayAsync() .ConfigureAwait(false); logicResult.Results = results; } catch (Exception ex) { logicResult.Exception = ex; } return(logicResult); }
public async Task <TransactionSearchResult> Handle(TransactionSearchCommand command, CancellationToken cancellationToken) { TransactionSearchResult logicResult = new TransactionSearchResult(); try { TransactionSelectArgs transactionSelectArgs = new TransactionSelectArgs(); TransactionSelectResult transactionSelectResult = await _transactionRepository.SelectAsync(transactionSelectArgs) .ConfigureAwait(false); transactionSelectResult.EnsureSuccess(); logicResult.Results = transactionSelectResult.Results; } catch (Exception ex) { logicResult.Exception = ex; } return(logicResult); }