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 static DomainDTOs.TransactionDTO ToDTO(this Transaction entity) { DomainDTOs.TransactionDTO convertedEntity = new DomainDTOs.TransactionDTO { TransactionId = entity.TransactionId, TransactionCode = entity.TransactionCode, TransactionName = entity.TransactionName, DebitAccountId = entity.DebitAccountId, CreditAccountId = entity.CreditAccountId, TransactionAmount = entity.TransactionAmount, IssuedTime = TimeUnit.FromTimeCode(entity.IssuedTimeCode) }; if (entity.DebitAccount != null) { convertedEntity.DebitAccountName = entity.DebitAccount.AccountName; } if (entity.CreditAccount != null) { convertedEntity.CreditAccountName = entity.CreditAccount.AccountName; } return(convertedEntity); }