Re: Datatable's Select and Compute methods

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Miha Markic [MVP C#] (miha)
Date: 09/27/04


Date: Mon, 27 Sep 2004 10:44:55 +0200


"MikeH" <MikeH@community.nospam> wrote in message
news:9D2BBAEF-D7CA-4F1F-BA30-00C89C2E07B3@microsoft.com...
> Example: A DataTable has 2 columns; KEY and COL_A. Column KEY is the
> PrimaryKey. A secondary key is also defined for COL_A. The keys are
> defined
> using the dataset designer.
>
> If I execute a SELECT method with filter: "COL_A = 'This'", will a lookup
> be
> performed using the secondary key or will every record in the table be
> searched for a match?
>
> I suspect the later which means the app will not scale well at all.

Yes, very probably Select doesn't utilize keys.
However, if you need to search values by keys, you might use use
DataTable.Rows.Find method or DataView.Find or FindRows methods.
And finally, there is a third way: create an indexing/searching mechanism by
yourself.

-- 
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com