Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Architecture
ASP.NET
ASP.NET MVC
ASP.NET WebForms
B2B (Business Integration)
BizTalk
Book Excerpts
Build and Deploy
C#
C++
Code Contracts
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Design Patterns
Development Process
Display Technologies
Distributed Computing
DotNetNuke
DSL
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Graphics
Internet Explorer 8.0
Interviews
iPhone
Java
Java Script
jQuery
LINQ
Linux
Mac OS X
MDX
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
Network
NHibernate
Object Oriented Development
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
Podcasts
Post Mortem
PowerPoint
Print/Output
Product News
Product Reviews
Project Management
Python
Q&A
Reporting Services
REST
RIA Services
Ruby
Search
Security
Services
SharePoint
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server CE/AnyWhere/Mobile/Compact
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
Tips
UI Design
UML
User Groups
VB Script
VB.NET
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WF
Whitepapers
Windows 7
Windows Azure
Windows Live
Windows Server
Windows Vista
WinForms
Workflow
WPF
XAML
XML
XNA
XSLT



INSTANTLY dtSearch® TERABYTES OF TEXT


 


CODE TRAINING


Reader rating:
Click here to read 3 comments about this article.
Article source: CoDe (2007 - Jul/Aug)


Article Pages:  1  2 3 4 5 - Next >


The Baker’s Dozen: A 13-Step Crash Course for Using LINQ

How many software tasks DON’T involve reading through data? Answer: very few. Developers work all the time with database data, XML data, DataSets, collections, lists, and arrays-all with different syntax and functionality for each one. Developers who write T-SQL code often covet set-based language statements when they work against other types of data. Additionally, developers who have coded against strongly-typed custom collections wish they could write SQL database queries with IntelliSense. Language Integrated Query (LINQ), a set of extensions to the .NET Framework for the next version of Visual Studio codename “Orcas”, brings the promise of integrated and uniform query capabilities to increase developer productivity when working with different types of data. While LINQ is a large topic worthy of books, this edition of The Baker’s Dozen will provide a crash course to learn what’s under the LINQ hood.

So what Exactly Is LINQ?

Odds are high that just about every .NET developer has at least heard of Language Integrated Query (LINQ). But since this is an intro, crash-course-style article on LINQ, I’ll assume very little.

"
Lambda expressions are a “kinder, gentler” form of anonymous methods.
"

LINQ is a set of extensions to the .NET Framework to query different types of data using a common language. The next release of Visual Studio (codenamed “Orcas”) will feature the following LINQ capabilities within .NET:

  • Querying Microsoft SQL Server data using a strongly-typed DataContext (LINQ to SQL)
  • Querying in-memory .NET objects (LINQ to Objects)
  • Querying .NET DataSets (LINQ to DataSets)
  • Querying XML Data (LINQ to XML)

LINQ offers something for just about everyone. If you’re writing database stored procedures and don’t need to change your approach, you may still find value in LINQ to DataSets or LINQ to Objects.

This article will present a number of code samples to demonstrate LINQ functionality. In addition, I’ll also cover new language enhancements in Visual Studio codename “Orcas” that work in conjunction with LINQ to allow developers to work with data more productively than ever before. As of this writing, LINQ has gone from the Community Technology Preview (CTP) phase to Beta 1, so odds are high that functionality will change. But the code samples should give you a good foundation for learning LINQ.

What’s on the Menu…

In creating the tips for this article, I wanted to provide basic exposure to as many areas of LINQ as possible. As I often do with intro articles and presentations, I try to build the types of examples that I previously sought when I learned a particular technology. So here are the 13 tips, in hopes of making you more aware of what’s under the LINQ hood, and what you can use it for.

  • Installing the beta and getting started
  • First steps for using LINQ to SQL by creating a strongly-typed DataContext
  • Writing LINQ to SQL queries
  • Standard LINQ querying syntax and operators, such as sorting, string searching, date handling, and SELECT DISTINCT
  • More querying syntax and operators, such as UNION and EXISTS, as well as SKIP/TAKE for paging and ANY/ALL condition handling
  • Using an extension method to convert a LINQ result set to an ADO.NET DataTable
  • Converting a LINQ result set to an IEnumerable or to a List
  • LINQ to XML
  • LINQ to DataSets
  • Lambda Expressions
  • LINQ to Objects
  • Language features for C# 3.0
  • Language features for VB 9.0

Additionally, at the end of the article I’ll list several valuable LINQ online references. Let’s get started with LINQ!

No ADO.NET Entity Framework (yet)

Microsoft’s data access strategy in .NET consists of two major components: one is LINQ, which this article covers. The other is the ADO.NET Entity Framework, a significant upgrade to ADO.NET that allows developers to create data models of the back-end database.

As I write this article (late April 2007), Microsoft has announced that the ADO.NET Entity Framework (which I’ll call Entity Framework throughout the remainder of this article) will not ship with Visual Studio codename “Orcas”, but will ship a few months later. The Entity Framework promises a richer development experience for creating and mapping entity data models to relational databases. You can read more about the Entity Framework here: http://blogs.msdn.com/data/archive/2007/04/28/microsoft-s-data-access-strategy.aspx

Given that Microsoft will not release the Entity Framework until after Visual Studio codename “Orcas” ships, I’ve decided to focus on areas of LINQ that are scheduled to be part of the Visual Studio codename “Orcas” release. In a future article I’ll cover the Entity Framework and Microsoft’s data access strategy.

&

By: Kevin S Goff

Kevin S. Goff, a Microsoft MVP award recipient for 2007, is the founder and principal consultant of Common Ground Solutions, a consulting group that provides custom Web and desktop software solutions in .NET, VFP, SQL Server, and Crystal Reports. Kevin is the author of Pro VS 2005 Reporting using SQL Server and Crystal Reports, published by Apress. Kevin has been building software applications since 1988. He has received several awards from the U.S. Department of Agriculture for systems automation. He has also received special citations from Fortune 500 Companies for solutions that yielded six-figure returns on investment. He has worked in such industries as insurance, accounting, public health, real estate, publishing, advertising, manufacturing, finance, consumer packaged goods, and trade promotion. In addition, Kevin provides many forms of custom training. Contact Kevin at kgoff@commongroundsolutions.net

kgoff@commongroundsolutions.net

Fast Facts

This article demonstrates the different areas of LINQ (LINQ to SQL LINQ to Objects, LINQ to XML, LINQ to DataSets), using the first official Beta for Microsoft Visual Studio codename “Orcas”.



Article Pages:  1  2 3 4 5 - Next Page: 'Page 2' >>


How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
4.3 out of 5

35 people have rated this article.

      Tower 48

 

CODE TRAINING