首页 > 代码库 > C# - linq查询现有的DataTable

C# - linq查询现有的DataTable

可以通过linq对现有的DataTable进行查询,并将结果拷贝至新的DataTable中例如:

// Query the SalesOrderHeader table for orders placed // after August 8, 2001.IEnumerable<DataRow> query =    from order in orders.AsEnumerable()    where order.Field<DateTime>("OrderDate") > new DateTime(2001, 8, 1)    select order;// Create a table from the query.DataTable boundTable = query.CopyToDataTable<DataRow>();

 

C# - linq查询现有的DataTable