add

Wednesday, May 27, 2009

LINQ Architecture and Components




LINQ is currently integrated directly into the native syntax for both C# 3.0 and VB 9.0 – which are included with Visual Studio 2008

Other languages may also support Language Integrated Query syntax in the future.
There are many flavors of LINQ which we describe by the type of data it operates over. As you can see here, LINQ may operate over Objects, SQL, Datasets, and XML.

These are the four flavors of LINQ that we are shipping with the .NET Framework 3.5

LINQ to Objects
SQL-like queries for any .NET collection (or anything that implements Ienumerable)
The LINQ to Objects API supports queries over any .NET collection, such as arrays and generic lists.

This API is defined in the System.Linq namespaces inside System.Core.dll
LINQ to objects is enabled by including the System.Linq namespace.
Manipulating collections of objects, which can be related to each other to form a hierary or a graph. From a certain point of view, LINQ to Objects is the default implementation used by a LINQ query.

LINQ to SQL
Query enabled data access framework

LINQ to XML
Query enabled, smaller, faster XML DOM

The important thing to remember is that the querying syntax used in LINQ is consistent regardless of the type of data you’re working with.

FAQ

Will there be support for Oracle with LINQ to SQL?

There is no provider model for DLINQ. In order for a third party provider to support DLINQ, they would need to produce an entire API that mirrors DLINQ that covers everything from query generation to examining attributes on classes to providing a designer to interact with the database schema. Because there's a lower bar for enhancing a provider to support the Entity Framework (primarily just query generation), Oracle is only planning to support the Entity Framework.
 

3 comments:

Manikandan S said...

Hi,
Thanks for sharing your knowledge to the world. I have some queries that, 1. Why LINQ has been introduced ie., for which purpose?
2. What is the difference in ADO and LINQ based operations?

Varun Sharma said...

Hi Mani..thanks for your comments.
Answering your 1st question:
There is a constant practice from Microsoft to release some unfinished low profile release before making a full force release.
They released Windows ME before releasing Win XP so that they get time to capture market review. Same happened between Xp and Win 7..they release Vista that was highly criticized .
Same things applies here.
The time when developers were trying to learn LINQ TO SQL they announced that they are launching all new framework named as LINQ to entity or entity framework that will cover all the pitfalls of LINQ TO sql..
When 1st version of LINQ was release it used to support
LINQ to SQL
LINQ To object
LINQ To XML..
The downfall was there that one used to manually create class object named as entity object to fire linq on that..
Very rapidly they overcome this thing by introducing automated entity creation via entity model where you just map the database table, it will automatically create entity class and you need to write only queries
Anyway they will defend their two version of framework with lot of pros and cons to show that this new thing is too good to use :)
I have read somewhere that Microsoft assign this LINQ design idea to two separate development them. One team came up with this LINQ to SQL where as the other team took the idea from 1st and presented the new with additional features

2nd question:
The main advantage of ADO and LINQ is around the time when data fetched from database and loaded to object
In ADO.Net, the data is fetched and loaded to Dataset or datatable as soon as you fire the SQLCommand..no matter whether you use that DataTable on very next line or not.

Where as LINQ works as late binding or lazy binding where data will be fetched only when you actually do want to fetch it..say
writing query
var qur=from o in dbcontext.Object
select o..
this qur will not fetch any data..
It will fetch only when you perform something like this qur.List() or any other operation

Varun Sharma said...

Secondly.. if you have used both ADO.Net and LINQ To Entity, to be honest, effort to devlop a n-tier application requires really around 30-40% less effort.
All work like creating data carrier , typed entity is taken care by the entity framework..
so it really helps to develop fast..It is from my practical experience and it looks very easy
Gone were the days where you need to setup connection string, SQLsommand, commandobject sending parameteres etc.