Page view counter

How Do I: LINQ to SQL: Executing Arbitrary SQL

This video shows how to execute any arbitrary SQL through the ExecuteCommand syntax and encapsulating the code through the partial DataContext class.

Presented by Scott Stanfield

Duration: 4 minutes, 9 seconds

Date: 13 March 2008

Watch the video   |   Get VB code  or  C# code

Video downloads: WMV | Zune | iPod | PSP | MPEG-4 | 3GP

Audio downloads: AAC | WMA | MPEG-4 | MPEG-3 | MPEG-2

Comments : 12

Leave a Comment

agarwaen : On March 17, 2008 8:05 PM said:

I know everyone is excited, so I be a bit more critic to this video podcast.

1. IMHO it is too short and too fast to the point. Not touching  it more deeply, i.e. why we are extending DataContext class instead of building our own factory, or it gets to the ExecuteCommand method just in the end of the video and then it immediately finish.

2. Would be better if Scott first of all told something about advantages/disadvantages of using SQL instead of LINQ (just a quick info and guide where to look for LINQ generated SQL statements), and touch in a bit more detail the ExecuteCommand method.

3. when will you support the "new" iPod Touch screen resolution in podcasts? It isn't much of a enjoyable experience watching them in present low-resolution state.

Thank you

mahir78 : On March 18, 2008 5:36 AM said:

Its Great that Microsoft offers world's smallest tutorials for their new products! Hats off to you. :(

atarikg : On March 20, 2008 7:35 AM said:

Well kinda fast yet nice :)

Nezdet : On March 25, 2008 7:47 AM said:

Fulltext Search I need to use pass through SQL to LINQ

Are there some exemples how to do it??

Lee Dumond : On April 08, 2008 1:35 PM said:

Just would like to point out a couple of errors in the code:

In part9.aspx, line 31:

Product p = db.Products.Single(p => p.ProductName == "Foo");

You can't declare a local variable "p" in the lambda expression here, because "p" is already used to denote the Product. You could change it to something else, like:

Product p = db.Products.Single(prod => prod.ProductName == "Foo");

In Helpers.cs, line 57:

return ExecuteCommand("delete from products where ProductId={0}", instance.ProductID);

DeleteProduct is a void method, so it can't return anything.  You need to get rid of the "return" keyword.

DesmondF : On May 26, 2008 5:22 AM said:

What about SQLInfoMessageHandler

I really enjoyed this tutorial. It got me going within a couple of minutes. I need to display the SQL messages from RAISERROR.

xequence : On June 11, 2008 2:36 PM said:

I would advise to whomever watches these tutorials that they are more understandable if you watch them in the correct order. Touching on specifics in every video is time consuming and Scott does a great job in not wasting time on old news.

cv_vikram : On August 18, 2008 10:55 AM said:

thanks....

TheDirtyBird : On August 21, 2008 2:11 PM said:

Could you please post a link where I can download this video?

KShips : On September 20, 2008 7:13 PM said:

Excellent videos. Learnt a lot from them.

Any chance of doing a video on how to apply security (ie behind a login) to this site? I'm a newbie so this might be quite obvious to implement but having issues with this project.

djibril_chimere_DIAW : On October 24, 2008 8:20 AM said:

Thanks! Jërëjëf!

brokensaber : On November 11, 2008 7:31 PM said:

I would like to see a video on using linq to import to a sql db using a data source like a csv file, xml, or xls.

Leave a Comment

You must be logged in to leave a comment. Click here to log in.

Microsoft Communities