Linq to SQL Example Tutorial - Visual Studio ORCAS March 2007 CTP - ASP.NET
by David Hayden ( Florida .NET C# SQL Server Developer ), Filed: Linq to SQL
I had a chance to play with Linq to SQL this evening in the Visual Studio ORCAS March 2007 CTP. Although I am sure a lot has changed since I played with it last, it has that same wonderful visual designer that I talked about here:
DLinq Designer - Visual Drag and Drop O/R Mapping Design Surface in Visual Studio 2005 - DLinq Tutorials
The visual designer for Linq to SQL makes things a snap, allowing you to drag SQL Server Database Tables from the Server Explorer to the designer surface. Linq to SQL creates all the classes, relationships, etc. for you as soon as you drop each table onto the surface.
Here is a quick Linq to SQL Tutorial I whipped together in about 5 minutes:

Database1 has a Subscribers Table in it for inserting new subscribers.

As shown in the project above, I added a new “Linq to SQL“ item to my website, called DataClasses1.dbml, which is a visual designer for Linq to SQL. As soon as I drag and drop my Subscribers Table from the Server Explorer to the Linq to SQL Visual Designer I get the following:

And that is it! Just code. Let's insert a new Subscriber into the Subscribers Table based on all the code that the Linq to SQL Visual Design Surface has generated for us under the covers:
DataClasses1DataContext context =
new DataClasses1DataContext();
Subscriber subscriber = new Subscriber();
subscriber.Name = "David Hayden";
subscriber.Email = "emailaddress";
context.Subscribers.Add(subscriber);
context.SubmitChanges();
I kept this example simple just to re-introduce the players and concepts in Linq to SQL, but of course you can persist entire object graphs with relationships, etc. Here is the newly inserted subscriber in the database that took about 5 minutes to code:

Conclusion
Linq to SQL is indeed cool and a useful O/R Mapper from Microsoft that will be released with Visual Studio ORCAS.
Linq to Sql Examples and Tutorials
Source: David Hayden ( Florida .NET C# SQL Server Developer )
Filed: Linq to SQL