开发者

How to group/categorize multiple datatables?

I have a series of datatables which are populated at run time and I would like a way to categorize and index them so that I can do a lookup to a specific datatable. I was thinking of having a datatable of datatables, ie whose rows contain a refer开发者_C百科ence to a datatable. Is there a better way you guys can think of to design this? Thanks.


You can store the datatables in a Dictionary

var allDataTables = new Dictionary<string, DataTable>();
if (allDataTables.Contains("DataTableA"))
{
   var dataTableA = allDataTables["DataTableA"];
   //work with datatable A
}


Why don't you use a Dictionary object to classify and categorize your data/data-tables? That way you don't have to mess the UI with more things... The lookup on a dictionary is also very fast. Hope that helps :)

Edit: seems that I posted in about the same time with @sll


Consider using a DataView. It automatically indexes its columns.


You'll want to use a DataSet which is a group of tables (and relations between them).

You produce a table and then add it to the DataSet through DataSet.Tables.Add()

More information on DataSet is located here: https://msdn.microsoft.com/en-us/library/system.data.dataset(v=vs.110).aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜