DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Linq Query To Get Records And Copy To Datatable

  • submit to reddit
        // linq query to get records and copy to datatable

 var query = from p in ds.Tables["Id"].AsEnumerable()      
        where p.Field<string>("ID") == "1" && p.Field<string>("Name") == "test"  select p;

   if (query.Count<DataRow>() > 0)
        dt = query.CopyToDataTable<DataRow>();