Using LINQ with C# 2012

October 24th, 2013 | Posted by Vidya Vrat in .NET | C# | LINQ - (0 Comments)

LINQ introduces a standard, unified, easy-to-learn approach for querying and modifying data, and can be extended to support potentially any type of data store. Visual Studio 2012 also supports LINQ provider assemblies that enable the use of LINQ queries with various types of data sources including relational data, XML, and in-memory data structures. Read Full Article Here
In this article, I will cover the following:

  • Introduction to LINQ
  • Architecture of LINQ
  • Using LINQ to Objects
  • Using LINQ to SQL
  • Using LINQ to XML

The following major features are included in this release:

  • Declarative data parallelism in the form of a LINQ implementation that parallelizes LINQ-to-Objects and LINQ-to-XML queries.
  • Imperative data and task parallelism through the Task Parallel Library in the System.Threading and System.Threading.Tasks namespaces.
  • A set of new coordination data structures in the System.Threading and System.Threading.Collections namespaces.
  • A user-mode work-stealing scheduler that makes efficient use of parallel hardware architectures.

Introduction to LINQ

February 15th, 2008 | Posted by Vidya Vrat in LINQ - (0 Comments)

Language-Integrated Query (LINQ) is an innovation which Microsoft made with the release of Visual Studio 2008 and the .NET Framework version 3.5 that promises to revolutionize the way that developers has been working with data before the release of .NET 3.5 having LINQ feature. LINQ introduces the standard and unified concept of querying various types of data sources falling in the range of relational database, XML documents or even in-memory data structures.

LINQ offers the following advantages:

  • LINQ unifies and offers the common syntax for querying any type of data source for example, you can query an XML document in the same way as you query a SQL database, an ADO.NET Dataset, an in-memory collection, or any other remote or local data source that you have chosen to get connected and accessed by using LINQ
    • LINQ bridges the gap and strengthens the connection between relational data and the object-oriented world.
    • LINQ speeds development time by catching many errors at compile time and have intellisense and debugging support.
    • LINQ query expressions (unlike a traditional SQL statement) are strongly typed.

Core LINQ Assemblies
—————————————————————————-
Assembly Name ———————|————————Description
————————————————————————–
System.LINQ (Provides classes and interfaces that supports Language-Integrated Query (LINQ) queries.
System.Collections.Generic(Allows users to create strongly typed collections that provide better type safety and performance than non-generic strongly typed collections
System.Data.LINQ(Provides the functionality to use LINQ to access the relational database.
System.XML.LINQ(Provides functionality for accessing XML documents using LINQ)
System.Data.Linq.Mapping(Designates a class as an entity class associated with a database)

Architecture of LINQ

January 17th, 2008 | Posted by Vidya Vrat in LINQ - (0 Comments)

LINQ consists of three major components:

*LINQ to Objects
*LINQ to ADO.NET, which includes
*LINQ to SQL (formerly called DLinq)
*LINQ to DataSet (formerly called LINQ over DataSet)
*LINQ to Entities
*LINQ to XML (formerly called XLinq)

The folloing figure depicts the LINQ architecture which clearly shows the various components of LINQ and their related data stores.

LINQ to Objects deals with in-memory data. Any class that implements the IEnumerable interface (in the System.Collections.Generic namespace) can be queried with Standard Query Operators.

LINQ to ADO.NET (also known as LINQ enabled ADO .NET) deals data from external sources, basically anything ADO.NET can connect to. Any class that implements IEnumerableor IQueryable (in the System.Query namespace) can be queried with Standard Query Operators. The LINQ to ADO.NET functionality could be achieved by using System.Data.Linq namespace.

LINQ to XML is a comprehensive API for in-memory XML programming. Like the rest of LINQ, it includes Standard Query Operators, and it can also be used in concert with LINQ to ADO.NET, but its primary purpose is to unify and simplify the kinds of things that disparate XML tools, like XQuery, XPath and XSLT are typically used to do. The LINQ to XML functionality could be achieved by using System.Xml.Linq namespace.