0

I have some TXT files which i load in DataTables ( in c# / .Net) So...my DataTable isn't binded to a "real" database like Oracle or SQL.

Now...i have to find some values in my dataTable. For the moment i simply use a for loop...The problem is i have large file and it's totally a waste of time.

I cannot use a Dictionnary because of duplicates keys..so, personnaly i want to continue to ue my DataTable.

If i'm not wrong, using LINQ is like using a for no ? It won't help me to gain time no?

So...i was thinking about binding a Dataview to my DataTable and creating my own index...What do you think ? Is it a good idea ?

Thanks a lot,

Walter Fabio Simoni
  • 5,671
  • 15
  • 55
  • 80
  • 2
    `DataTable.Select(string filterExpression)`? But if performance becomes an issue, creating a `DataView` with an index seems wise. – 15ee8f99-57ff-4f92-890c-b56153 Nov 07 '16 at 16:22
  • 1
    upvote @EdPlunkett comment. However, how you need to use that index matters. Read [DataView Performance](https://msdn.microsoft.com/en-us/library/bb669089(v=vs.110).aspx). In there are links on filtering and sorting using LINQ-to-DataSet. – radarbob Nov 07 '16 at 18:14
  • Check out [`LookUp`](https://msdn.microsoft.com/en-us/library/bb460184(v=vs.110).aspx#Remarks). Quote: *A Lookup resembles a Dictionary. The difference is that a Dictionary maps keys to single values, whereas a Lookup maps keys to collections of values.* – radarbob Nov 07 '16 at 18:19
  • How big are your text files? Perhaps you should use a search engine like Lucene.NET. – Alexander Petrov Nov 07 '16 at 20:42
  • Hello, thanks, will try Datatable.select, but how using a "TRIM" in the FilterExpression please ? Thanks – Walter Fabio Simoni Nov 08 '16 at 09:03
  • Hello, i tried the Selec() method of DataTable and....it's more long than iterate ! So, have to try with index and dataview i think ! – Walter Fabio Simoni Nov 08 '16 at 09:50

0 Answers0