.NET Tip: Where Is Your Data Coming From? Burlington WI

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

R.E. Coker and Associates, Inc.
262-723-8104
108 W Court St.
Elkhorn, WI
R S InfoCon, Inc.
262-898-7456
2320 Renaissance Blvd
Sturtevant, WI
Mathis Development
(262) 767-8780
2351 Partridge Woods Ct
Burlington, WI
Hillman Consulting Services
(262) 338-6147
5085 S Oak Rd
West Bend, WI
Pronto Progress
(262) 524-5500
W229N1433 Westwood Dr Ste 203
Waukesha, WI
Bungeecraft Technologies
(414) 449-9105
4824 W Medford Ave
Milwaukee, WI
Transcendent
(262) 953-2750
N19W24400 Riverwood Dr Ste 220
Waukesha, WI
Spherion
(608) 233-8201
1 Pierce Place Itasca
Madison, WI
Vpn Dominion Corp
(414) 535-1453
8627 W Lynx Ave
Milwaukee, WI
Hawkridge Enterprises
(608) 647-2366
19126 Campbell Hill Dr
Richland Ctr, WI

.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

R.E. Coker and Associates, Inc.

262-723-8104
108 W Court St.
Elkhorn, WI
http://www.recoker.com

Related Articles
- DB Data Generator Burlington WI
DB Data Generator is a data generation tool that generates randomized data for database load testing, quality assurance testing, usability testing and performance testing. Read on to learn more about DB Data Generator's key features.
- GURA Object Director and Data Gate Burlington WI
- Downloaded Data Guard Burlington WI
- Data Secure Encryption Platform Burlington WI
- Purisma Data Hub Burlington WI
- Attunity Stream Client/Server Platform Burlington WI
- Data Profiler Burlington WI
- Sybase Data Integration Suite Burlington WI
- ADRC Data Recovery Tools Burlington WI
Related Articles
- DB Data Generator Burlington WI
DB Data Generator is a data generation tool that generates randomized data for database load testing, quality assurance testing, usability testing and performance testing. Read on to learn more about DB Data Generator's key features.
- GURA Object Director and Data Gate Burlington WI
- Downloaded Data Guard Burlington WI
- Data Secure Encryption Platform Burlington WI
- Purisma Data Hub Burlington WI
- Attunity Stream Client/Server Platform Burlington WI
- Data Profiler Burlington WI
- Sybase Data Integration Suite Burlington WI
- ADRC Data Recovery Tools Burlington WI
Related Local Event
Wisconsin Entrepreneurs' Conference
Dates: 6/9/2008 - 6/10/2008
Location: Hyatt Regency Hotel
Milwaukee WI
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