2 min read

Create web site project and add LinqDataSource control

Open Visual Studio 2008 from its shortcut on the desktop. Click File | New | Web Site…(or Shift+Alt+N) to open the New Web Site window. Change the default name of the site to a name of your choice (herein LinqDemo)on your local web server as shown. Make sure you are creating a .NET Framework 3.5 web site as shown here.

Learning SQL Server 2008 Reporting Services

Drag and drop a LinqDataSource control from Toolbox|Data shown in the next figure on to the Default.aspx

Learning SQL Server 2008 Reporting Services

This creates an instance of the control LinqDataSource1 as shown. The figure also shows the smart tasks of this control as shown.

Learning SQL Server 2008 Reporting Services

Create a data context for the LinqDataSource control

In order to use this control you also need to create a data context. Right click the localhost web site and choose Add New Item…to open the Add New Item – http://localhost/ LinqDemo window as shown.

Learning SQL Server 2008 Reporting Services

In the Visual Studio installed templates highlight Linq to SQL Classes. Change the default name from DataClasses.dbml to a name of your choosing. Herein MyDC.dbml. Click Add. This pops-up a Microsoft Visual Studio warning message as shown. The preferred location for this file is in the App_Code folder of your project as suggested here.

Learning SQL Server 2008 Reporting Services

Click on Yes. This adds a MyDC.dbml file to APP_Code folder as shown. MyDC.dbml consists of two components MyDC.dbml and MyDC.designer.vb to the App_Code folder as shown .

Learning SQL Server 2008 Reporting Services

Double click the MyDC.dbml node in the APP_Code folder. This opens the ObjectRelational Designer and the designer surface with two panes as shown. Read the instructions in the windows. In the left pane you can drag and drop items from the Server Explorer in Visual Studio to create the appropriate classes and in the right pane you can drag and drop stored procedures. In this article we will be looking at just creating classes from table objects.

Learning SQL Server 2008 Reporting Services

LEAVE A REPLY

Please enter your comment!
Please enter your name here