2.6. LINQ to DataSet

In the previous section, you saw how LINQ to SQL supports ADO.NET transactions. This is not the only integration between the "old" ADO.NET library and the "new" LINQ to SQL. In fact, LINQ to SQL can use ADO.NET DataSets with LINQ to DataSet.

With some limitations, LINQ to DataSet allows developers to use DataSets as normal data sources using the usual LINQ query syntax.

Listing 2-27 shows a simple example that uses a LINQ query to fill a typed dataset.

Example 2-27. Filling a Typed DataTable with the CopyToDataTable Method
dsPeople ds = new dsPeople(); dsPeople.RoleRow row = ds.Role.NewRoleRow(); row.ID = 1; row.RoleDescription = "Manager"; ds.Role.AddRoleRow(row); row = ds.Role.NewRoleRow(); row.ID = 2; row.RoleDescription ...

Get LINQ for Visual C# 2008 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.