开发者

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

开发者 https://www.devze.com 2022-12-28 03:44 出处:网络
Greetings, 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

Greetings,

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

开发者_C百科

is there a way to optimize this?

BR,


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号