Select TOP 5 * from SomeTable, using Dataview.RowFilter ?
- by eugeneK
I need to select 5 most recent rows from cached Dataview object, is there any way to do that?
I've tried but Indexer DataColumn is empty. :
public static DataView getLatestFourActive()
{
DataTable productDataTable = getAll().ToTable();
DataColumn ExpressionColumn = new DataColumn("Indexer",typeof(System.Int32));
ExpressionColumn.Unique = true;
ExpressionColumn.AutoIncrement = true;
ExpressionColumn.AllowDBNull = false;
ExpressionColumn.AutoIncrementSeed = 0;
ExpressionColumn.AutoIncrementStep = 1;
productDataTable.Columns.Add(ExpressionColumn);
DataView productFilteredView = productDataTable.DefaultView;
productFilteredView.RowFilter = "isActive=1 and Indexer<4";
return productFilteredView;
}
getAll() returns cached DataView
thanks