.NET Tip: Where Is Your Data Coming From? Aptos CA

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

Fiorano Software, Inc.
408-354-3210
718 University Avenue, Suite 212
Los Gatos, CA
AuditSolutions
(408) 997-4888
3150 Almaden Expressway #250
San Jose, CA
Inawave Systems
(831) 687-0532
Aptos, CA
Benz Pamela J
(831) 688-8684
Aptos, CA
Bean Creek Partners
(831) 662-2746
7360 Viewpoint Rd
Aptos, CA
Trinus Corp
(818) 246-1143
330 N Brand Blvd
Glendale, CA
P C Processors
(925) 926-0646
2890 N Main St
Walnut Creek, CA
Micropac Technologies
(714) 751-9100
655 Baker St
Costa Mesa, CA
Codeobjects Inc
(408) 432-1180
1381 McCarthy Blvd
Milpitas, CA
Accounting On Computers Incorporated
(707) 837-8634
Windsor, CA

.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

Fiorano Software, Inc.

408-354-3210
718 University Avenue, Suite 212
Los Gatos, CA
http://www.fiorano.com?src=zdnetbsd

Related Articles
- Purisma Data Hub Aptos CA
Purisma Data Hub (PDH) is a Master Data Management (MDM) platform, a product that enables organizations to collect, correlate, standardize, and manage core business data-such as customer or vendor records and attributes-for consistent use and access throughout their organizations.
- DB Data Generator Aptos CA
- GURA Object Director and Data Gate Aptos CA
- Data Secure Encryption Platform Aptos CA
- Attunity Stream Client/Server Platform Aptos CA
- ADRC Data Recovery Tools Aptos CA
- Downloaded Data Guard Aptos CA
- Sybase Data Integration Suite Aptos CA
- Data Profiler Aptos CA
Related Articles
- Purisma Data Hub Aptos CA
Purisma Data Hub (PDH) is a Master Data Management (MDM) platform, a product that enables organizations to collect, correlate, standardize, and manage core business data-such as customer or vendor records and attributes-for consistent use and access throughout their organizations.
- DB Data Generator Aptos CA
- GURA Object Director and Data Gate Aptos CA
- Data Secure Encryption Platform Aptos CA
- Attunity Stream Client/Server Platform Aptos CA
- ADRC Data Recovery Tools Aptos CA
- Downloaded Data Guard Aptos CA
- Sybase Data Integration Suite Aptos CA
- Data Profiler Aptos CA
Related Local Events
OMG Technical Meeting
Dates: 12/8/2008 - 12/12/2008
Location: Hyatt Regency
Santa Clara CA
View Details

SPIE's Photonics West 2009
Dates: 1/24/2009 - 1/29/2009
Location: San Jose Convention Center
San Jose CA
View Details

SPIE Advanced Lithography (Formerly Microlithography)
Dates: 2/22/2009 - 2/27/2009
Location: San Jose Convention Center
San Jose CA
View Details

Design and Verification Conference & Exhibition (DVCon)DVCon is the premier conference on the usage of HDLs and HVLs?y.networks in a new, instructor led seminar
Dates: 2/24/2009 - 2/26/2009
Location: DoubleTree Hotel San Jose
San Jose CA
View Details

Software Development Conference & Expo
Dates: 3/9/2009 - 3/13/2009
Location:
Santa Clara CA
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