I have an app which uses a dataset. eg.
public class mainData
{
public string itemID { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
public string address { get; set; }
}
I have 4 other data sets which are imported API data from other apps which have the 'same' data (eg same type of fiends) but use different names. eg,
public class importedData1
{
public string itemsID { get; set; }
public string fName { get; set; }
public string lName { get; set; }
public string add { get; set; }
}
Each of the 4 sets is different.
What I'm doing at the moment is:
Importing data from the API of the new data (eg. importedData1)/
Created a function to convert that data into the mainData class model by doing a foreach loop on each of the records in the imported data.
public static mainData ConvertData1(importedData1 item) { mainData sxData = new mainData () { itemID = item.itemsID, firstName = item.fname, lastName = item.lname, address = item.add}; return sxData; }
(apologies, the indentation is having issues in stack) I then have 4 of these functions, 1 for each of the imported data sets.
Is this an 'ok' way to achieve this?
if it was just a single set of data to another I was going to use {get;set} within the main Model however with all 4 I thought this would start getting very mixed up as there are some crossovers in naming convention but with different object types!