Reputation: 1845
this is the list of table which is not same data type
-DataTableOne
int idOne;
string name;
-DataTableTwo
int idTwo;
int id;
getter, setter and service is been implemented for this tow classes
now i have the list from DataTableOne like 10 records and want to create new DataTableTow in action
//i can not create the DataTableTow list by geting the loop from DataTableOne
List<DataTableOne> listOne = service.ListAll(); //will return 10 records
List<DataTableTwo> listTwo = null;
for(DataTableOne row : listOne){
// how to add data of the DataTableOne and add it to the listTwo
}
thanks in advance.
Upvotes: 0
Views: 100
Reputation: 1845
//Entity class of the DataTableTwo was not correctly initialized.
List<DataTableOne> listOne = service.ListAll(); //will return 10 records
List<DataTableTwo> listTwo = null;
for(DataTableOne row : listOne){
listTwo.add(new DataTableTwo(row.getIdOne(), 1)); //there are two integer and you can form any how you want.
}
Upvotes: 1