LINQ (Language Inegrated Query), pronounced as "link" is a Microsoft .NET components that adds data querying capabilities to .NET languages (VB/C#). 1
There are different ways to set-up your application to be LINQ-SQL enabled. The one that i'll be showing you is very straight forward, using the LINQ to SQL Classes.
Let's assumed you already have your database information and you have access right. You can try by checking the Data Connections of the Server Explorer on Visual Studio 2010 or Database Explorer for the older versions. Your should be able to see your database as connected.
Here are the steps to integrate LINQ to SQL:
1. Expand the Solution Explorer
2. Select the Project where you want to add the LINQ to SQL Classes, then right click. Click "Add" --> "New Item.."
3. On the new window, expand the "Visual C#" (or Visual Basic if your language is Visual Basic), click on the "Data". Then on the center portion, select "LINQ to SQL Classes".
4. At the bottom part of that window, replace the name with your desired name. Leave the ".dbml" extension. Click "Add". Notice that new item has been added to your project.
5. Double click new added file to open the "LINQ to SQL Classes" Designer. It is the file with the ".dbml" file extension.
6. Open the Server Explorer window, you should see your database when you expand Data Connections.
7. Expand the "Tables" of your database and then select then drag and drop the table names you want to use to the designer page or window. You now see the table with the fields and their relationship if there is any.
8. Your LINQ project is now linked to SQL.
To make a LINQ statement, use the "DataContent" of the System.Data.Linq. Unfortunately, it is not covered in this article. Hope to post one that discuss about that into much details.
Reference:
1 http://en.wikipedia.org/wiki/LINQ
L.
Integrate LINQ to SQL
Lerrie | Wednesday, September 21, 2011 | Labels: ASP.NET, LINQ, SQL Server, Visual Studio
Subscribe to:
Post Comments (Atom)





0 comments:
Post a Comment