I have a DataTablecontaining 2000 entries.
DataTable
How would you extract the first 100 entries in DataTable?
If it implements IEnumerable<T>:
IEnumerable<T>
var first100 = table.Take(100);
If the type in question implements only IEnumerable, you can use the Cast extention method:
var first100 = table.Cast<Foo>().Take(100);
This works for DB2.
select * from table fetch first 100 rows only;
mysql: select * from table limit 100
select * from table limit 100
- this, foreach 100 .
, MS SQL:
Select top 5 * from MyTable2
MS SQL .
n # 2.0:
DataTable dt = new DataTable(); var myRows = new List<DataRow>(); //no sorting specified; take straight from the top. for (int i = 0; i < 100; i++) { myRows.Add(dt.Rows[i]); }
Source: https://habr.com/ru/post/1735431/More articles:Determine current Mac Safari webpage using Python - pythonCruiseControl.NET Queue Priority - continuous-integrationHow can I get warning output from the PowerShell cmdlet programmatically in version 1.0? - powershellHow to determine which function call throws an exception in Python? - pythonПочему фильтры Solr отключены при выполнении нечетких поисков? - luceneMsbuild find all directories containing a file named xxxx - msbuildLaunching plug-in updates with the Eclipse interface - command-lineExtract resource file from exe - c ++Возможное исключение NullreferenceException - c#Excel Sheets with XML - xmlAll Articles