Fire up an instance of Visual Studio 2008 and create a new C# Windows Forms Application project. In
the Solution Explorer, expand the References node, right-click on it, and select Add Reference from the
context menu. In the Add Reference dialog opens, make sure that the .NET tab is selected, and scroll
down the list until you see the System.Data.Linq component. Select that component and click OK.
88
Chapter 4: LINQ Standard Query Operators
Next, open Form1 in design view and place two buttons and a list box on the form. Name one of the
buttons cmdExecuteQuery and the other cmdClose. Then view the code behind the form and replace the
existing code with the following (this code can also be obtained from the Chapter 4 example in the file
download for this chapter):
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Linq;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
namespace LINQ
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void cmdClose_Click(object sender, EventArgs e)
{
Application.
Pages:
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174