| |   Skin:   
      User: Not logged in 
Newsletter Signup
XSLT Library
Latest XML Blogs
Featured Examples
Featured Articles
Book Chapters
Training Courses
Sign In
My Profile
My Articles
My Examples
My Favorites
My Resources
Add a Resource
About Me
My Blog
HeadGeek Articles
Talking Portfolio
World Trip Pics

Author: phanindra yerra
Published: 6/20/2006 12:09 AM
Category: C#
Summary: In this Article I shortly explained Dlinq and Xlinq


The LINQ Project is a codename for a set of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations. It extends C# and Visual Basic with native language syntax for queries and provides class libraries to take advantage of these capabilities.


Find out about the general-purpose query facilities added to the .NET Framework that apply to all sources of information, not just relational or XML data. This facility is called .NET Language Integrated Query (LINQ).


the next big challenge in programming technology is to reduce the complexity of accessing and integrating information that is not natively defined using OO technology. The two most common sources of non-OO information are relational databases and XML.


The extensibility of the query architecture is used in the LINQ project itself to provide implementations that work over both XML and SQL data. The query operators over XML (XLinq) use an efficient, easy-to-use in-memory XML facility to provide XPath/XQuery functionality in the host programming language. The query operators over relational data (DLinq) build on the integration of SQL-based schema definitions into the CLR type system. This integration provides strong typing over relational data while retaining the expressive power of the relational model and the performance of query evaluation directly in the underlying store.

<b> Example </b>


using System;

using System.Query;

using System.Collections.Generic;


class app {

  static void Main() {

    string[] names = { "Burke", "Connor", "Frank",

                       "Everett", "Albert", "George",

                       "Harris", "David" };


    IEnumerable<string> expr = from s in names

                               where s.Length == 5

                               orderby s

                               select s.ToUpper();


    foreach (string item in expr)





<b> OutPut</b>









The arguments to the Where, OrderBy, and Select operators are called lambda expressions, which are fragments of code much like delegates. They allow the standard query operators to be defined individually as methods and strung together using dot notation. Together, these methods form the basis for an extensible query language.

SQL Integration

.NET Language Integrated Query can be used to query relational data stores without leaving the syntax or compile-time environment of the local programming language. This facility, code-named DLinq, takes advantage of the integration of SQL schema information into CLR metadata. This integration compiles SQL table and view definitions into CLR types that can be accessed from any language.

DLinq defines two core attributes, [Table] and [Column], which indicate which CLR types and properties correspond to external SQL data. The [Table] attribute can be applied to a class and associates the CLR type with a named SQL table or view. The [Column] attribute can be applied to any field or property and associates the member with a named SQL column. Both attributes are parameterized to allow SQL-specific metadata to be retained. For example, consider this simple SQL schema definition:


create table People (

    Name nvarchar(32) primary key not null,

    Age int not null,

    CanCode bit not null



create table Orders (

    OrderID nvarchar(32) primary key not null,

    Customer nvarchar(32) not null,

    Amount int



The CLR equivalent looks like this:



public class Person {

  [Column(DbType="nvarchar(32) not null", Id=true)]

  public string Name;



  public int Age;



  public bool CanCode;




public class Order {

  [Column(DbType="nvarchar(32) not null", Id=true)]

  public string OrderID;


  [Column(DbType="nvarchar(32) not null")]       

  public string Customer;



  public int? Amount;



XML Integration

.NET Language Integrated Query for XML (XLinq) allows XML data to be queried using the standard query operators as well as tree-specific operators that provide XPath-like navigation through descendants, ancestors, and siblings. It provides an efficient in-memory representation for XML that integrates with the existing System.Xml reader/writer infrastructure and is easier to use than W3C DOM. There are three types that do most of the work of integrating XML with queries: XName, XElement and XAttribute.

XName provides an easy to use way to deal with the namespace-qualified identifiers (QNames) used as both element and attribute names. XName handles the efficient atomization of identifiers transparently and allows either symbols or plain strings to be used wherever a QName is needed.

XML elements and attributes are represented using XElement and XAttribute respectively. XElement and XAttribute support normal construction syntax, allowing developers to write XML expressions using a natural syntax:



var e = new XElement("Person",

                     new XAttribute("CanCode", true),

                     new XElement("Name", "Loren David"),

                     new XElement("Age", 31));


var s = e.ToString();


This corresponds to the following XML:

<Person CanCode="true">

  <Name>Loren David</Name>





XElement dovetails with the query operators, allowing developers to write queries against non-XML information and produce XML results by constructing XElements in the body of a select clause:


var query = from p in people where p.CanCode select new XElement("Person", new XAttribute("Age", p.Age), p.Name);


This query returns a sequence of XElements. To allow XElements to be built out of the result of this kind of query, the XElement constructor allows sequences of elements to be passed as arguments directly:


var x = new XElement("People", from p in people where p.CanCode select
 new XElement("Person", new XAttribute("Age", p.Age), p.Name));

This XML expression results in the following XML:


<People>   <Person Age="11">Allen Frances</Person>
   <Person Age="59">Connor Morgan</Person> </People>






Fans of "The Office"
Dwight Bobbleheads are here!
  “It's me! I'm the bobblehead! Yes!”

Advertise on XMLPitstop

Advertise on XMLPitstop

EggHead Cafe
Web Servicee development
Buy text ads here!
internet backup
Color Laser Printer
Marc jacobs sunglasses
Skype vs. sipcall
VoIP Internettelefonie
Buy text ads here!

Interested in Text ads?
2,223 Total Members
36 members(last 30 days)
8 members(last 7 days)
2 members(today)

1,609 Total Discussions
12 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

17,260 Total Blog Posts
1,839 Blogs(last 30 days)
342 Blogs(last 7 days)
49 Blogs(today)

8,699 Newsgroup Posts
0 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

13,786 Total Resources
5 Resources(last 30 days)
1 Resources(last 7 days)
0 Resources(today)


David Silverlight's| 2801 Florida Ave #225|Miami, FL 33133|Ph:305-447-1139