.NET Tip: Where Is Your Data Coming From? Washington

LINQ can be used for much more than just accessing data stored in your database. Learn how you can use the from clause with other types of data.

Local Companies

Veradis Technologies LLC
425.463.8819
3222 187th PL SE
Bothell, WA
Avalara
206-780-7000
900 Winslow Way E
Bainbridge Island, WA
Fuze Digital Solutions
425-649-1246
12819 SE 38th St., Ste. 505
Bellevue, WA
Quardev, Inc.
206-547-7771
3411 Thorndyke Ave W
Seattle, WA
Pacific Edge Software
425.897.8800
2606 116th Ave NE
Bellevue, WA
Axcis.Net
360-293-3000 x102
7104 NE 181st St
Kenmore, WA
Scherrer Company
(206) 297-6168
6250 3rd Ave. NW
Seattle, WA
Web eStore
360-260-3750
3508 NE 109th ave. #U4
Vancouver, WA
Jataayu Software Inc.
+1.425.641.1225
1402, 140th PL , NE
Bellevue, WA
ERI Economic Research Institute
1.800.627.3697
8575 164th Ave. NE, Suite 100
Redmond, WA

.NET Tip: Where Is Your Data Coming From?

provided by: 
Originally published at Internet.com


LINQ to Objects allows you to use LINQ queries with any object that support IEnumerable or IEnumerable(T). This means that you can use LINQ to acccess data in arrays, lists, dictionaries, and other collections. You also can use LINQ with any of your own classes that implement or inherit IEnumerable. Let me start with a very simple introduction using an array of integers. This following example uses LINQ to find all of the even integers in an array of integers: // Array of data int[] Data = { 17, 32, 51, 98, 87, 4, 63, 26, 75, 40 }; // Create the variable to store the query var EvenNumbers = from Num in Data where Num % 2 == 0 select Num; // Run the query and output the results foreach (int i in EvenNumbers) Debug.Print(i.ToString());

Data is simply an integer array. The only thing important about it is that arrays implement IEnumerable so LINQ can be used with them. The statement of interest in this example is the definition of EvenNumbers. The from clause is used to define a subset of the elements in Data. Num is called the range variable and is used to represent each element from the data source. The where clause is used here to include only those numbers that are evenly divisible by 2, eliminating all odd numbers. The select clause indicates what information about each Num should be included for each matching element. In this case, the number itself is being selected. One point to note is that at this point the query has not been executed. EvenNumbers is simply a definition of the query. The query is not actually processed until it is used in the foreach loop that follows. The piece is the foreach loop that iterates over the EvenNumbers query and prints out each included element. The result is the following: 32 98 4 26 40

I hope this whets your appetite for what LINQ can do and will help you to think about where you can use LINQ in your application. LINQ allows you to use a SQL-like syntax for working with your data outside of the database.

About the Author

Jay Miller is a Software Engineer with Electronic Tracking Systems, a company dedicated to robbery prevention, apprehension, and recovery based in Carrollton, Texas. Jay has been working with .NET since the release of the first beta and is co-author of Learn Microsoft Visual Basic.Net In a Weekend. Jay can be reached via email at jmiller@sm-ets.com.

Author: Jay Miller

Read article at Internet.com site

Featured Local Company

Essential Security Software

359-992-8926
11040 Main St
Bellevue, WA
http://www.essentialsecurity.com

Related Articles
Regional Articles
- .NET Tip: Where Is Your Data Coming From? Anacortes WA
- .NET Tip: Where Is Your Data Coming From? Arlington WA
- .NET Tip: Where Is Your Data Coming From? Auburn WA
- .NET Tip: Where Is Your Data Coming From? Bainbridge Island WA
- .NET Tip: Where Is Your Data Coming From? Battle Ground WA
- .NET Tip: Where Is Your Data Coming From? Bellevue WA
- .NET Tip: Where Is Your Data Coming From? Bellingham WA
- .NET Tip: Where Is Your Data Coming From? Bothell WA
- .NET Tip: Where Is Your Data Coming From? Bremerton WA
- .NET Tip: Where Is Your Data Coming From? Buckley WA
- .NET Tip: Where Is Your Data Coming From? Camas WA
- .NET Tip: Where Is Your Data Coming From? Chehalis WA
- .NET Tip: Where Is Your Data Coming From? Cheney WA
- .NET Tip: Where Is Your Data Coming From? East Wenatchee WA
- .NET Tip: Where Is Your Data Coming From? Edmonds WA
- .NET Tip: Where Is Your Data Coming From? Ellensburg WA
- .NET Tip: Where Is Your Data Coming From? Enumclaw WA
- .NET Tip: Where Is Your Data Coming From? Everett WA
- .NET Tip: Where Is Your Data Coming From? Federal Way WA
- .NET Tip: Where Is Your Data Coming From? Gig Harbor WA
- .NET Tip: Where Is Your Data Coming From? Issaquah WA
- .NET Tip: Where Is Your Data Coming From? Kelso WA
- .NET Tip: Where Is Your Data Coming From? Kenmore WA
- .NET Tip: Where Is Your Data Coming From? Kennewick WA
- .NET Tip: Where Is Your Data Coming From? Kent WA
- .NET Tip: Where Is Your Data Coming From? Kirkland WA
- .NET Tip: Where Is Your Data Coming From? Lacey WA
- .NET Tip: Where Is Your Data Coming From? Lake Stevens WA
- .NET Tip: Where Is Your Data Coming From? Lakewood WA
- .NET Tip: Where Is Your Data Coming From? Longview WA
- .NET Tip: Where Is Your Data Coming From? Lynden WA
- .NET Tip: Where Is Your Data Coming From? Lynnwood WA
- .NET Tip: Where Is Your Data Coming From? Maple Valley WA
- .NET Tip: Where Is Your Data Coming From? Marysville WA
- .NET Tip: Where Is Your Data Coming From? Mercer Island WA
- .NET Tip: Where Is Your Data Coming From? Moses Lake WA
- .NET Tip: Where Is Your Data Coming From? Mount Vernon WA
- .NET Tip: Where Is Your Data Coming From? Mountlake Terrace WA
- .NET Tip: Where Is Your Data Coming From? Mukilteo WA
- .NET Tip: Where Is Your Data Coming From? Oak Harbor WA
- .NET Tip: Where Is Your Data Coming From? Olympia WA
- .NET Tip: Where Is Your Data Coming From? Pasco WA
- .NET Tip: Where Is Your Data Coming From? Port Angeles WA
- .NET Tip: Where Is Your Data Coming From? Port Orchard WA
- .NET Tip: Where Is Your Data Coming From? Poulsbo WA
- .NET Tip: Where Is Your Data Coming From? Pullman WA
- .NET Tip: Where Is Your Data Coming From? Puyallup WA
- .NET Tip: Where Is Your Data Coming From? Redmond WA
- .NET Tip: Where Is Your Data Coming From? Renton WA
- .NET Tip: Where Is Your Data Coming From? Richland WA
- .NET Tip: Where Is Your Data Coming From? Seattle WA
- .NET Tip: Where Is Your Data Coming From? Sedro Woolley WA
- .NET Tip: Where Is Your Data Coming From? Selah WA
- .NET Tip: Where Is Your Data Coming From? Sequim WA
- .NET Tip: Where Is Your Data Coming From? Shelton WA
- .NET Tip: Where Is Your Data Coming From? Silverdale WA
- .NET Tip: Where Is Your Data Coming From? Snohomish WA
- .NET Tip: Where Is Your Data Coming From? Spanaway WA
- .NET Tip: Where Is Your Data Coming From? Spokane WA
- .NET Tip: Where Is Your Data Coming From? Stanwood WA
- .NET Tip: Where Is Your Data Coming From? Sumner WA
- .NET Tip: Where Is Your Data Coming From? Tacoma WA
- .NET Tip: Where Is Your Data Coming From? University Place WA
- .NET Tip: Where Is Your Data Coming From? Vancouver WA
- .NET Tip: Where Is Your Data Coming From? Washougal WA
- .NET Tip: Where Is Your Data Coming From? Wenatchee WA
- .NET Tip: Where Is Your Data Coming From? Woodinville WA
- .NET Tip: Where Is Your Data Coming From? Yakima WA
- .NET Tip: Where Is Your Data Coming From? Yelm WA
Related Local Events
Tech Execs Seattle CIO Panel Forum
Dates: 1/9/2009 - 1/9/2009
Location: Qwest Field
Seattle WA
View Details

Tech Execs Seattle IT Solutions Conference and Showcase
Dates: 4/8/2009 - 4/8/2009
Location: Bell Harbor International Conference Center
Seattle WA
View Details

SpecOps West
Dates: 6/2/2009 - 6/4/2009
Location: Greater Tacoma Convention & Trade Center
Tacoma WA
View Details

Technology Convergence: The Integrated Lifestyle
Dates: 10/9/2008 - 10/9/2008
Location: Silverdale Beach Hotel
Silverdale WA
View Details

Seattle Cisco ASA Training: 2 Day Hands On Seminar
Dates: 10/1/2008 - 10/2/2008
Location: Holiday Inn Express SeaTac Airport
Seattle WA
View Details
Rate Article
     
Articles Insider

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Advertising Engineering Home Services Retail & Consumer Services
Business Services Entertainment Industrial Goods & Services Software
Career Family Insurance Technology
Cars Financial Services Internet Telecommunications
Computer Hardware Food & Beverage Legal Transportation & Logistics
Construction Health Pets Travel
Education Home Electronics Real Estate Wedding