Tuesday, May 18, 2010

What is Linq,DLinq & XLinq?

The Linq project offers querying features integrated right into programming languages. This will allow executing strongly-typed queries on sources such as databases, XML documents or even object graphs in memory. This technology relies on innovations on programming languages like C# 3 or VB.NET 9, and it will be ported to other .NET languages like Delphi.

DLinq is an extension to Linq that allows querying a database (only SQL Server for the moment) and do object-relational mapping.
XLinq is an extension to Linq that allows querying XML documents, as well as creating or transforming XML.

Like for DLinq,
Here is what is performed in each case:

We just execute a simple query: return
  from
cst in _db.Customers
 
where cst.Country == country
 
select cst;
we can map through the all records using IEnumerable or IQueryable object.

Like for XLinq,

  // Load XML
  var webCustomers = XElement.Parse(xmlData);

  // Create view
  var result = from customer in customers, webCustomer in webCustomers.Elements()
      where customer.CustomerID == webCustomer.Attribute("ID").Value
      select new {
        ID = customer.CustomerID,
        Name = customer.CompanyName,
        EMail = webCustomer.Attribute("EMail").Value,
        WebSite = webCustomer.Attribute("WebSite").Value};

  // Display
  ObjectDumper.Write(result);

 regards,



No comments:

Post a Comment