.net - Boxing/unboxing in DataTables and LINQ -
let's i've got memory-based datatable this:
datatable dt = new datatable(); dt.columns.add("c1", system.type.gettype("system.double")); dt.columns.add("c2", system.type.gettype("system.double")); ... datarow row = dt.addrow(); row["c1"] = 1; row["c2"] = 2; ...
then query table:
list<datarow> rows = (from r in table (double)r["c1"] < 2.0 select r).tolist();
and in profiler see creates lot of doubles. assume somehow related comparison.
any ideas how rid of needless memory allocation?
i use .net 4, vs 2010, c#.
the underlying storage here in typed array (in case in doublestorage
class), access goes via object
, since there no generic api. cannot avoid boxing unless switch class-based model without datatable
.
Comments
Post a Comment