Deconstructing LINQ to SQL - Craig Nicholson

Craig Nicholson

My blog has moved to http://craign.net/.

News

My blog has moved to http://craign.net/.


AfrigatorI shmaak SA Blogs, sorted with Amatomu.comSign the petition for Xbox LIVE in South Africa. Locations of visitors to this page

Communities

Development Blogs

Development Tools

General Tools

Personal

Deconstructing LINQ to SQL

I happened to stumble upon the blog of Mike Taulty and the following three very interesting articles on how LINQ actually works.

The first article looks at Lambda expressions and introduces the interface IQueryable<T> which inherits from IEnumerable<T> and Expression property to represent the expression tree (Expression<T>). The second article explores the IQueryable<T> interface a bit more and applies it to a simple array of integers to explain the concepts. The third article goes a little deeper and attempts to explain how the standard ADO.NET objects like SqlConnection and SqlCommand are used to build the final Transact-SQL query.

Unfortunately it seems like the LINQ classes are a bit of a zoo meaning that it'll take a lot of patience and persistence to understand them in-depth.

I still have doubts in my mind as to whether LINQ is something really worth pursuing as I am a firm believer that application coders should not be accessing tables in database directly but should rather use SQL Server (or any other RDBMS) stored procedures as the database interface.

Comments

Mike said:

You can use stored procedures from within Linq to SQL as it stands right now. You can also use database functions.

Thanks,

Mike.

# March 19, 2007 11:45 PM

Trivium DawnWalker said:

Correct me I'm wrong but linQ is also used for exploring collections. I could be way off but I seem to remember Ruari doing a demo at DevDays last years using linQ to select certain elements from a string array.

# March 20, 2007 5:37 AM

Ernst Kuschke said:

"...should rather use SQL Server (or any other RDBMS) stored procedures as the database interface."

LINQ provides for this ;o) Trust me: LINQ will change the way we work with data permanently.

Trivium, LINQ enables you to query anything implementing IEnumarable, so that includes collections and arrays.

# March 20, 2007 10:18 AM

ahmeds said:

Linq can be used against stored procs as well

# March 20, 2007 10:45 AM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# March 20, 2007 7:45 PM

Craig Nicholson said:

Well thats good news that it can be used to call stored procedures but is it as simple as working with tables?

# March 20, 2007 7:48 PM

ahmeds said:

See http://weblogs.asp.net/scottgu/archive/2006/06/18/DLINQ-with-Stored-Procedures.aspx and the links on that page. The syntax might have changed a bit but the high level concept should be the same

# March 21, 2007 6:29 PM

Ernst Kuschke said:

Yip ;)

# March 22, 2007 4:56 AM

Trivium DawnWalker said:

I haven't had enough time to check it out in detail but I agree with Ernst, its looking really really good. I really think you should reconsider your view on it. So pursue it ;)

# March 22, 2007 8:13 AM