Making a selection in C # datatable

I have a datatable with a row of rows in it, the first column is Int32, and I want to make a simple selection:

select * from MyDataTable where column1 = 234
+3
source share
4 answers

Try to get the result as an array of strings:

DataRow[] rows = myDataTable.Select("column1 = 234");

Or this to get a dataview:

DataView myDataView = myDataTable.DefaultView;
myDataView.RowFilter = "column1 = 234";
+6
source
var result = from row in table.AsEnumerable()
             where row[0].Equals(42)
             select row;

or

var result = table.AsEnumerable().Where(row => row[0].Equals(42));
+2
source

System.Data.DataTable, datatable.Rows.Find primaryKey datatable.Select , .

// DataTable

datatable.Rows.Find(234);

//

datatable.Rows.Find(234, 1, 4);

//,

datatable.Select("column1=234");

// Compound Select

datatable.Select("column1=234 AND column2=1");
+1

Source: https://habr.com/ru/post/1705038/


All Articles