O'Reilly logo

LINQ for Visual C# 2008 by Fabio Claudio Ferracchiati

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required