Bernie Cook's Blog

Azure, C#, .NET, Architecture & Related Tech News


1 Comment

Reviewing the T-SQL Generated by LINQ to SQL Within SQL Server Profiler

SQL Server ProfilerIf you’re interested in taking a look at the final T-SQL generated by your LINQ to SQL queries then you have a few options available:
 

  1. Utilise LINQPad which converts your C# LINQ database queries into T-SQL
  2. Execute an SQL Server Profiler trace against the database your application is querying while its running
  3. Understand how ADO.NET translates the LINQ to SQL expression tree into T-SQL so you know what it’s going to output

I thought I’d blog about the second option above given it’s the more common approach I adopt when I’m working with LINQ to SQL. Continue reading

Advertisements


Leave a comment

IQueryable, IEnumerable & List – What’s the Difference?

Back when .NET 2 was released in 2006 Lists appeared and I remember having one of those “OMG this is fantastic moment for coding“. You could immediately see the benefits – how they’d reduce the amount of code you had to write and increase readability. Prior to that in .NET 1.1 there was IEnumerable, which I can’ t say was something I made a lot direct use of, with emphasis on the word “direct”. I utilised a number of classes that implemented IEnumerable (SortedList, Hashtable, List, etc.) but, unlike today, it wasn’t a class that I worked with directly. Then a few years later .NET 3.5 was released and IQueryable was brought into the mix and suddenly I started having to think a touch more about which one was the “right” one to use when it came to manipulating a collection of objects. Continue reading