Skip to Content
ASP.NET 3.5 For Dummies®
book

ASP.NET 3.5 For Dummies®

by Ken Cox
February 2008
Intermediate to advanced
428 pages
8h 52m
English
For Dummies
Content preview from ASP.NET 3.5 For Dummies®

8.5. Updating Data with a LINQ Query

LINQ to SQL does more than just select data for viewing: It selects it for updates as well. You use the query to get a subset of the data (maybe a subset with just one item) and then loop through the item(s) to do updates. In this section, you add multiple exclamation marks (!) to some items and view the results.

The follow sections insert strange content (exclamation marks) into your Northwind database. Make sure that you have a clean copy of the database set aside for future use.

8.5.1. Exclaiming with an Extension method

When you type in Code view (see Figure 8-6), you've no doubt seen IntelliSense pop up all those interesting functions like ToLower(), ToUpper(), and ToExclaim(). Okay, maybe you haven't seen ToExclaim() yet in IntelliSense, but you're about to!

Figure 8-6. IntelliSense for the extension method ToExclaim().

Extension methods let you tack on functions of your own. The only catch is that the extension code must be wrapped in a Visual Basic Module, not in the .aspx page itself. Follow these steps to create the ToExclaim() extension method:

  1. In your project's App_Code folder, add a new text file named extmodule.vb (FileAdd New ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 3.5 Unleashed

ASP.NET 3.5 Unleashed

Stephen Walther
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9780470195925Purchase book