SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 352 | Next

Scott Klein

"Professional LINQ"

This section of
the chapter walks you through a full example that updates, inserts, and deletes data using LINQ to SQL.
Fire up your copy of Visual Studio and create a new C# Windows project. On Form1, place three buttons
and a text box. Name the first button cmdInsert, the second button cmdUpdate, and the third button
cmdDelete. Make sure that the text box is long enough to hold and view 20 characters.
For this example, you need to add a reference to LINQ, so in Solution Explorer, right-click on References
and select Add Reference. When the Add Reference dialog appears, make sure that the .NET tab is
221
Part III: LINQ to SQL
selected and scroll down until you see the System.Data.Linq component name. Select that component
and click OK.
Next, right-click on Form1 and select View Code. Add the following line to the rest of the
using statements:
using System.Data.Linq;
Time to start adding the good stuff.
Insert
Let??™s begin by discussing Insert operations. First, add the following to the form code below the partial
class for Form1:
public class AdventureWorks : DataContext
{
public AdventureWorks(string connection) : base(connection) {}
public Table Contact;
}
This should look familiar??”it??™s the code from the strongly typed section a few pages ago.


Pages:
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6