Book Image

LINQ Quickly

By : N Satheesh Kumar
Book Image

LINQ Quickly

By: N Satheesh Kumar

Overview of this book

<p>This book gets you started with LINQ and shows how it will make your programming life easier by making use of new features from the .NET Framework 3.0. This book is split into seven chapters, each of which is dedicated to presenting a feature of LINQ and its usage in real-life scenarios. <br /><br />Language Integrated Query (LINQ) is a new feature in Visual Studio 2008 that extends its query capabilities, using C# and Visual Basic. Visual Studio 2008 comes with<br />LINQ provider assemblies that enable the use of LINQ with data sources such as in-memory collections, SQL relational databases, ADO.NET Datasets, XML documents, etc.<br />In Visual Studio 2008, Visual C# and Visual Basic are the languages that implement the LINQ language extensions. LINQ language extensions use the new standard query operators API, which is the query language for any collection that implements IEnumerable&lt;T&gt;.</p>
Table of Contents (14 chapters)
LINQ Quickly
Credits
About the Author
About the Reviewer
Preface
Building an ASP.NET Application
LINQ with Outlook

Preface

Language Integrated Query (LINQ) is a new feature in Visual Studio 2008 that extends its query capabilities using C# and Visual Basic. Visual Studio 2008 comes with LINQ provider assemblies that enable the use of LINQ with data sources, such as in-memory collections, SQL relational databases, ADO.NET Datasets, XML documents, etc. In Visual Studio 2008, Visual C# and Visual Basic are the languages that implement the LINQ language extensions. LINQ language extensions use the new standard query operators, API, which is the query language for any collection that implements IEnumerable<T>.

This book introduces the reader to the basic concepts of LINQ, and takes them through using LINQ with an example-driven approach.

What This Book Covers

Chapter 1 looks at the overall features of LINQ, and gives an overview of different operators provided by LINQ to operate on objects, XML, relational databases, etc.

Chapter 2 examines LINQ to Objects, which means that you can use LINQ to query objects in a collection. Using this feature, you can access in-memory data structures using LINQ. You can directly query collections, and filter out required values without using powerful filtering, ordering, and grouping capabilities.

Chapter 3 looks at LINQ to XML. It is a new in-memory XML programming API to work against XML data. There are different ways of creating XML trees in .NET. LINQ to XML is the new method of creating and manipulating XML data through .NET. The properties and methods of LINQ help in navigating and manipulating XML elements and attributes.

Chapter 4, which covers LINQ to SQL, takes care of translating LINQ expressions into equivalent T-SQL, passing it onto the database for execution, and then returning the results back to the calling application. It reduces programming time and comes with two different design-time tools, which are used for converting relational database objects into object definitions. It also has the ability to create databases, and database objects.

Chapter 5 examines LINQ to DataSets. An ADO.NET DataSet provides a disconnected data source environment for applications. It can be used with multiple data sources. A DataSet has the flexibility of handling data locally in cache memory where the application resides. The application can continue working with a DataSet when it is disconnected from the source and is not dependent on the availability of the data source. The DataSet maintains information about the changes made to data so that updates can be tracked and sent back to the database as soon as the data source is available or reconnected.

Chapter 6 covers LINQ to XSD. It enhances XML programming by adding the feature of typed views on un-typed XML trees. LINQ to XSD gives a better programming environment by providing the object models generated from XML schemas. This is called typed XML programming.

Chapter 7 looks at standard query operators provided by LINQ, and how you can use some of them against different data sources.

Appendix A takes you through building a simple ASP.NET application using LINQ.

Appendix B tells you how to access Outlook objects using LINQ.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

There are three styles for code. Code words in text are shown as follows: "LINQ queries work on sources which are IEnumerable<>. The new ADO.NET provides a feature for getting the rows enumerated by applying AsEnumerable() on DataTables."

A block of code will be set as follows:

public class Icecream
{
public string Name { get; set; }
public double Price { get; set; }
}

New terms and important words are introduced in a bold-type font.

Words that you see on the screen, in menus or dialog boxes, for example, appear in our text like this: "You can see DataTables listed in the DataSet Visualizer."

Reader Feedback

Feedback from our readers is always welcome. Let us know what you think about this book, what you liked or disliked. Reader feedback is important for us to develop titles that you get the most out of.

To send us general feedback, simply drop an email to , making sure to mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email www.packtpub.com/authors.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer Support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the Example Code for the Book

Visit http://www.packtpub.com/support, and select this book from the list of titles to download any example code or extra resources for this book. The files available for download will then be displayed.

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the Submit Errata link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata are added to the list of existing errata. The existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Questions

You can contact us at if you are having a problem with some aspect of the book, and we will do our best to address