Reputation: 25
Would there be a performance issue if I use object type for my property class? instead of assigning them individually with datatypes and converting them one by one. I've used object to avoid conversion and improve performance. Or am I doing it wrong? Please guide me. Thanks.
DataSet ds = new DataSet();
List<DynamicData> details = new List<DynamicData>();
Queries qr = new Queries();
ds = qr.GetCacheableSP();
foreach (DataRow dtrow in ds.Tables[0].Rows)
{
DynamicData tbl_roads_avg_roughness = new DynamicData();
tbl_roads_avg_roughness.site_category_func_class = dtrow["site_category_func_class"];
tbl_roads_avg_roughness.csurvey_with_data = (dtrow["csurvey_with_data"]);
tbl_roads_avg_roughness.ctotal_length = (dtrow["ctotal_length"]);
tbl_roads_avg_roughness.caverage_iri = (dtrow["caverage_iri"]);
tbl_roads_avg_roughness.date_imported = dtrow["date_imported"];
tbl_roads_avg_roughness.color = dtrow["color"];
tbl_roads_avg_roughness.csurvey_with_data_total = (dtrow["csurvey_with_data_total"]); ;
tbl_roads_avg_roughness.ctotal_length_total = (dtrow["ctotal_length_total"]);
tbl_roads_avg_roughness.tbl_roads_avg_roughness_access = true;
details.Add(tbl_roads_avg_roughness);
}
return details.ToArray();
public class DynamicData
{
public object site_category_func_class { get; set; }
public object csurvey_with_data { get; set; }
public object ctotal_length { get; set; }
public object caverage_iri { get; set; }
public object date_imported { get; set; }
public object color { get; set; }
public object csurvey_with_data_total { get; set; }
public object ctotal_length_total { get; set; }
public object tbl_roads_avg_roughness_access { get; set; }
}
Upvotes: 0
Views: 39
Reputation: 76258
This is premature optimization. Strong typing doesn't incur any more overhead than dealing with dynamic/object types.
As your app grows, you're sacrificing the safety net of compile time checks, intellisense and basically every language feature that C# offers.
Use a functional language or even use node.js if strong typing (or serialization) bothers you that much.
Upvotes: 1