LINQ TO SQL, ADO.NET Entity Framework, T-SQL


I have a few applications/websites running with LINQ to SQL and the other day I decided to go ahead and optimize some of the queries, etc and I found that the size for variable length data types is derived from the parameter value instead of the column actual size?

for example a column is defined as nvarchar(30). when I use linq to query that column with a value that's 5 characters long the parameter in sp_executesql will be defined as nvarchar(5)...this causes a major procedure cache bloat even for a small utility site that has a lot of queries

is there a way to optimize this?



In EF 1, it's the same as the L2S behavior you're seeing. In EF 4, a default length of 4000 is used, so the query won't bloat the cache for different param values.

Need Your Help

how to convert time with decimal point to time correctly using strtotime and date function?

php date strtotime

I am trying to convert a 1.3 to 1:30 but when I use strtotime with date function 1.3 is becoming 1.03 !!!

Maya right click context sensitive menu

python contextmenu menuitem maya right-click

I am trying to edit the right click context sensitive menu from Maya. I have found how to add a menuItem but I would like to have this Item in the top of the list not at the bottom... I think in this