Update specific values from one collection into other

  • Thread starter Thread starter abdi81
  • Start date Start date
A

abdi81

Guest
Hello,

I have below code:

var personalizedData = "TransactionLocationID,Amount";


List<SXARCMTransactionDetails> lstTransactions = new List<SXARCMTransactionDetails>();
lstTransactions.Add(new SXARCMTransactionDetails() {TransactionID = 1, Amount =22,TransactionLocationID = 9 });
lstTransactions.Add(new SXARCMTransactionDetails() { TransactionID = 2, Amount = 23, TransactionLocationID = 10 });

List<SXARCMTransactionDetails> lstTransactionsToUpdate = new List<SXARCMTransactionDetails>();
lstTransactionsToUpdate.Add(new SXARCMTransactionDetails() { TransactionID = 1, Amount = 0, TransactionLocationID = 0 });
lstTransactionsToUpdate.Add(new SXARCMTransactionDetails() { TransactionID = 2, Amount = 0, TransactionLocationID = 0 });

I want to update the column values of all the rows in "lstTransactionsToUpdate" with values present in "lstTransactions". The name of the columns are there in "personalizedData" string.

SXARCMTransactionDetails is nothing but a class which holds properties such as TransactionID, Amount, etc. TransactionID is an unique primary key which will be present in both the lists.

Please let me know how this can be achieved.

Below is the link to console app:

ConsoleApp2 - Google Drive


Abdi

Continue reading...
 
Back
Top