Skip to content

Instantly share code, notes, and snippets.

@pingkunga
Created March 18, 2025 02:26
Show Gist options
  • Save pingkunga/11618386e48b2d05aa464fef842dae13 to your computer and use it in GitHub Desktop.
Save pingkunga/11618386e48b2d05aa464fef842dae13 to your computer and use it in GitHub Desktop.
Back to Basic: Fundamental Data Structure in C#
public static void ProcessTransactionWithOnlyList(IList<TransactionDTO> pTransactions, IList<PortfolioDTO> pPortfolios, IList<PortPriceSouceDTO> pPortPriceSources)
{
// Iterate through transactions and find corresponding portfolio
foreach (var transaction in pTransactions)
{
// Use LINQ to find the portfolio with the matching PortfolioId
var portfolio = pPortfolios.FirstOrDefault(p => p.PortfolioId == transaction.PortfolioId);
if (portfolio != null)
{
// You can save or process the transaction with the portfolio here
//....
}
var portPriceSource = pPortPriceSources.FirstOrDefault(p => p.PortfolioId == transaction.PortfolioId);
if (portPriceSource != null)
{
// You can save or process the transaction with the portfolio here
//....
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment