Datatable Select Method

 I always use .NET SDK documentation whenever I need any help on syntax/concepts. Today I thought about this weired requirement. Suppose if I want to know the method name of any ADO.NET object which returns a DataTable, what is the easiest way to get the information?

Why do we have only two overloaded versions of DataTable.Select method

public DataRow[] Select(string);
public DataRow[] Select(string, string, DataViewRowState);

Why not another overloaded version which returns DataTable itself like this

public DataTable Select(string, string);

Because when you want to sort the filtered rows after the select method, you need to load those datarows into one table and create a view and then sort(sigh!). If we had another overloaded version of select which returns just DataTable, we can directly create the dataview and filter instead of loading.


 

1 Comment

  • There is a version of Select that takes two strings. The first String is the filter expression and the second string is a sort expression.



    OrderTable.Select("Status = Open", "Required DESC")

Comments have been disabled for this content.