Sunday, 15 March 2015

c# - Inplace Datatable modification instead of using "Defaultview.ToTable" -



c# - Inplace Datatable modification instead of using "Defaultview.ToTable" -

i working on algorithm convenient utilize datatables it's implementation.

as part of algorithm maintain sorting datatable it's first columns using:

dt.defaultview.sort = dt.columns[0].columnname + " asc"; dt = dt.defaultview.totable(); // evil line

the problem is, seems dt.defaultview.totable(); relatively heavy operation memory , time wise (it takes 60 percent of algorithm's time!), , plenty algorithm have handle big amounts of data.

i aware can sort manually, hate reinvent wheel...

so, aware of way job done without relocating total tables each , every time, , without reinventing wheel?

a fuller sample of code:

var dt = new datatable(); /*populating dt...*/ (int = 0; < input.length; i++) { /*some more code here includes modifying first column*/ dt.defaultview.sort = dt.columns[0].columnname + " asc"; dt = dt.defaultview.totable(); }

c# performance datatable

No comments:

Post a Comment