November 18, 2009 10:25 by
bryan
Having been using LINQ to SQL for some time now, I came across my very first issue "There is already an open DataReader associated with this Command which must be closed first." it's been some time since I had this issue.
The issue only appears on one database and that is being held on a SQL 2000 box.
The solution, sorry work around, is to transfer the results in to Lists using ToList() after each LINQ call.
I have found it hard to replicate in my test environment, as it only happens on a clients installation.
David Foderick posted a similar issue he had with the Entity Framework
After speaking with Eric Nelson, he pointed out that SQL 2000 has a lack of support for MARS, however there is no planning to provide support for this, however SQL Azure does not allow MARS. So perhaps this issue will get addressed some time in the future?
8fa555d7-f52d-44c9-83fd-056115b8ec1c|1|1.0
September 2, 2009 19:05 by
bryan
096de7c4-c46c-42b3-aa88-5486ebcee06b|0|.0
May 26, 2009 15:10 by
bryan
I was wondering today if anyone had produced any benchmarks on the speed and performance of LINQ, so I had a look around and found that LINQ 2 SQL is 4 times faster than the Entity Framework. Why is this? It is due the the fact that the Entity Framework is a more generic solution, where as LINQ to SQL can be more fine tuned to the underlying database structure.
Here are a few links I found that might explain things in more details
ADO.NET Entity Framework Performance Comparison
How Slow is 'Slow'?
5617c8a8-9ab5-4cc7-b381-89c6221a5b6a|0|.0
May 26, 2009 09:06 by
bryan
I have found LINQ to SQL and the Entity Framework has a few missing features, one of these is the ability to update the designer diagrams, and this is where Huagati DBML come to play.
Huagati DBML/EDMX Tools is an add-in for Visual Studio that adds functionality to the Linq2SQL/DBML diagram designer in Visual Studio 2008, and to the ADO.NET Entity Framework designer in Visual Studio 2008 SP1.
0b79adaf-6a27-4899-b136-d296f733a983|1|5.0
April 17, 2009 09:55 by
bryan
When you need to find if any records exist in a table or a selective snap shot of a table, you are prehaps like me in using the COUNT(*) SQL transaction and see if there are zero counts, but is this the most efficient method?
After a performance issue on one of my applications I found a new extension to LINQ to SQL called ANY(), from Ray Booysen on StackOverflow, here is an example of the SQL that is generated from LINQ:

The Results:
SELECT COUNT(*) AS [value] FROM [dbo].[Employees] AS [t0]
9
SELECT (CASE WHEN EXISTS(SELECT NULL AS [EMPTY] FROM [dbo].[Employees] AS [t0]) THEN 1 ELSE 0 END) AS [value]
True
As you can see LINQ wins the day again.
a5461286-ed45-4f9c-b0df-e80b13c2bbe7|1|2.0
March 17, 2009 11:56 by
bryan
What with the release of LINQ to Entities, and LINQ to SQL, which one performs better?
For comparison of performance it is worth chekcing out Eric's blog, but I still perfer LINQ to SQL.
Not that I would use the Entity Framework yet, see my article on this
b6e4e9a7-4054-44a8-9bea-71f05504b207|0|.0
March 6, 2009 11:17 by
bryan
There comes a time when you are using LINQ to SQL that you just have to find out what SQL is being generated, for what ever reason that is, here a a few ways to get the SQL you are looking for:
You can use SQL Server Profile to see the traffic going to and from the database

But if you are like me you want more control over your processes, so you can use the DataContext.Log, and output the log to a window, or in the case below the console window

One last method is to just write out an objects SQL, using the GetCommand, as seen below

07733fcc-6ea4-44fe-8624-a67692e05a3d|1|3.0
February 27, 2009 12:41 by
bryan
Just found a great LINQ tool for quering any database LINQPad, is so useful I almost fell off my chair when I found it.
If you're using LINQ then this is a must on a list of tool you need to have.
When I was using it I thought it would be nice to have Autocompletion, and it does, so long as you register the product.
ca0db9e4-c887-4cf5-bee0-996aeea75b04|1|5.0
February 4, 2009 08:59 by
bryan
I've come across two issues with the Entity Framework, one that effects any language and one just for VB.NET
It's quite simple, the Entity Framework generates edmx files, however that Inherits Global.System.Data.Objects.DataClasses.EntityObject, which means when you create your Partial class you can not Inherit from your own base class.
The second issue is related to VB.NET, as if you are intending to use Dependence Injection or IoC you need to have an Interface defined and to implement an Interface in VB.NET you must add Implements after each Property and Method, which you can not do as the framework generates it's own code.
I've attached both C# and VB.NET examples, none of which compile
Entity Framework Issues.zip (42.58 kb)
d63eb5bd-d694-4dc7-ae78-c86fb1e12f1d|0|.0
January 23, 2009 09:18 by
bryan
When you start to play with the Entity Framework you will soon come up with the need to store your connection in a common place. To do this you will need to with provide the connection string to the Entity Object Context or provide the Entity Connection. I prefer to us the Entity Connection as you can explicity define each section of the connection.
C#

VB.NET

and if you need to pass in the UserID and Password

For some more help on setting this up check out Ricka on Dynamic Data
79d4bf43-e1dc-4058-a13d-7b0a63407106|0|.0