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

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

Wireless Direct
1.866.707.8498
BOX 71101
shorewood, WI
R S InfoCon, Inc.
262-898-7456
2320 Renaissance Blvd
Sturtevant, WI
Visionary Computer Solutions
262-365-9430
PO Box 406
Grafton, WI
Acumium
608 310 9700 x 522
5133 West Terrace Drive Suite 300
Madison, , WI
IFS
414-577-5191
12000 W. Park Place
Milwaukee, WI
R.E. Coker and Associates, Inc.
262-723-8104
108 W Court St.
Elkhorn, WI
HarrisData
800-225-0585
13555 Bishops Court
Brookfield, WI
Electroniclaim
262-240-9700
11357 N. Port Washington Rd
Mequon, WI
Xorbix Technologies Inc.
414-277-5044
759 N. Milwaukee St.
Milwaukee, WI
HarrisData
262-784-9099
13555 Bishop's Court, Suite 300
Brookfield, 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

Acumium

608 310 9700 x 522
5133 West Terrace Drive Suite 300
Madison, , WI
http://www.acumium.com

Related Articles
- ADRC Data Recovery Tools Wisconsin
Data Recovery Tools by ADRC contains a collection of DIY data recovery software that supports a variety of drives and file systems. This data recovery software utilizes a GUI with novice users in mind.
- Data Profiler Wisconsin
- Purisma Data Hub Wisconsin
- Sybase Data Integration Suite Wisconsin
- GURA Object Director and Data Gate Wisconsin
- DB Data Generator Wisconsin
- Downloaded Data Guard Wisconsin
- Data Secure Encryption Platform Wisconsin
- Attunity Stream Client/Server Platform Wisconsin
Regional Articles
- .NET Tip: Where Is Your Data Coming From? Appleton WI
- .NET Tip: Where Is Your Data Coming From? Baraboo WI
- .NET Tip: Where Is Your Data Coming From? Beaver Dam WI
- .NET Tip: Where Is Your Data Coming From? Beloit WI
- .NET Tip: Where Is Your Data Coming From? Brookfield WI
- .NET Tip: Where Is Your Data Coming From? Burlington WI
- .NET Tip: Where Is Your Data Coming From? Cedarburg WI
- .NET Tip: Where Is Your Data Coming From? Chippewa Falls WI
- .NET Tip: Where Is Your Data Coming From? Cudahy WI
- .NET Tip: Where Is Your Data Coming From? De Pere WI
- .NET Tip: Where Is Your Data Coming From? Delavan WI
- .NET Tip: Where Is Your Data Coming From? Eau Claire WI
- .NET Tip: Where Is Your Data Coming From? Elkhorn WI
- .NET Tip: Where Is Your Data Coming From? Fond Du Lac WI
- .NET Tip: Where Is Your Data Coming From? Fort Atkinson WI
- .NET Tip: Where Is Your Data Coming From? Franklin WI
- .NET Tip: Where Is Your Data Coming From? Green Bay WI
- .NET Tip: Where Is Your Data Coming From? Hartland WI
- .NET Tip: Where Is Your Data Coming From? Janesville WI
- .NET Tip: Where Is Your Data Coming From? Kaukauna WI
- .NET Tip: Where Is Your Data Coming From? Kenosha WI
- .NET Tip: Where Is Your Data Coming From? La Crosse WI
- .NET Tip: Where Is Your Data Coming From? Lake Geneva WI
- .NET Tip: Where Is Your Data Coming From? Manitowoc WI
- .NET Tip: Where Is Your Data Coming From? Marinette WI
- .NET Tip: Where Is Your Data Coming From? Marshfield WI
- .NET Tip: Where Is Your Data Coming From? Menasha WI
- .NET Tip: Where Is Your Data Coming From? Menomonee Falls WI
- .NET Tip: Where Is Your Data Coming From? Menomonie WI
- .NET Tip: Where Is Your Data Coming From? Merrill WI
- .NET Tip: Where Is Your Data Coming From? Middleton WI
- .NET Tip: Where Is Your Data Coming From? Milwaukee WI
- .NET Tip: Where Is Your Data Coming From? Mosinee WI
- .NET Tip: Where Is Your Data Coming From? Mukwonago WI
- .NET Tip: Where Is Your Data Coming From? Muskego WI
- .NET Tip: Where Is Your Data Coming From? Neenah WI
- .NET Tip: Where Is Your Data Coming From? New Berlin WI
- .NET Tip: Where Is Your Data Coming From? Oak Creek WI
- .NET Tip: Where Is Your Data Coming From? Oconomowoc WI
- .NET Tip: Where Is Your Data Coming From? Onalaska WI
- .NET Tip: Where Is Your Data Coming From? Oshkosh WI
- .NET Tip: Where Is Your Data Coming From? Pewaukee WI
- .NET Tip: Where Is Your Data Coming From? Racine WI
- .NET Tip: Where Is Your Data Coming From? Rhinelander WI
- .NET Tip: Where Is Your Data Coming From? Rice Lake WI
- .NET Tip: Where Is Your Data Coming From? River Falls WI
- .NET Tip: Where Is Your Data Coming From? Schofield WI
- .NET Tip: Where Is Your Data Coming From? Shawano WI
- .NET Tip: Where Is Your Data Coming From? Sheboygan WI
- .NET Tip: Where Is Your Data Coming From? South Milwaukee WI
- .NET Tip: Where Is Your Data Coming From? Stevens Point WI
- .NET Tip: Where Is Your Data Coming From? Sturgeon Bay WI
- .NET Tip: Where Is Your Data Coming From? Sun Prairie WI
- .NET Tip: Where Is Your Data Coming From? Superior WI
- .NET Tip: Where Is Your Data Coming From? Thiensville WI
- .NET Tip: Where Is Your Data Coming From? Two Rivers WI
- .NET Tip: Where Is Your Data Coming From? Watertown WI
- .NET Tip: Where Is Your Data Coming From? Waukesha WI
- .NET Tip: Where Is Your Data Coming From? Waupaca WI
- .NET Tip: Where Is Your Data Coming From? Wausau WI
- .NET Tip: Where Is Your Data Coming From? West Bend WI
- .NET Tip: Where Is Your Data Coming From? Whitewater WI
- .NET Tip: Where Is Your Data Coming From? Wisconsin Rapids WI
Related Local Events
2008 Early Stage Symposium
Dates: 11/5/2008 - 11/6/2008
Location: Monona Terrace
Madison WI
View Details

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