You can use DataTable.Select
:
var strExpr = "CostumerID = 1 AND OrderCount > 2";
var strSort = "OrderCount DESC";
// Use the Select method to find all rows matching the filter.
foundRows = ds.Table[0].Select(strExpr, strSort);
Or you can use DataView
:
ds.Tables[0].DefaultView.RowFilter = strExpr;
UPDATE I'm not sure why you want to have a DataSet returned. But I'd go with the following solution:
var dv = ds.Tables[0].DefaultView;
dv.RowFilter = strExpr;
var newDS = new DataSet();
var newDT = dv.ToTable();
newDS.Tables.Add(newDT);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…