I have the following class called HIP
using System;
namespace Shared
{
public class HIP
{
public HIP ()
{
}
public double data_source { get; set; }
public string hid { get; set; }
public double wid { get; set; }
public double psn { get; set; }
}
}
And I got the oData and adding each properties to the List as follows:
var client= new ODataClient(settings);
var packages =await client.For("HIP").FindEntriesAsync();
protected List<HIP> hcp = new List<HIP>();
foreach (var package in packages)
{
hcp.Add(new HIP {wid=Convert.ToSingle(package["wid"])});
hcp.Add(new HIP {hid=package["hid"].ToString()});
hcp.Add(new HIP {psn=Convert.ToSingle(package["psn"])});
hcp.Add(new HIP {data_source=Convert.ToSingle(package["data_source"])});
}
My question is how to get foreach operation in optimal/better way. Now, I have 4-5 properties and I could type each property names as follows package["wid"]
,package["hid"]
,package["psn"]
,package["data_source"]
; however what if I have a tens of properties. I would like to know is there a better way to iterate.