gpt4 book ai didi

sql - 为什么LINQ发送sp_executesql而不是直接执行SQL?

转载 作者:行者123 更新时间:2023-12-04 05:05:35 25 4
gpt4 key购买 nike

例如,LINQ to SQL发送以下消息:

exec sp_executesql 
N'SELECT [t0].[HomeID],
[t0].[Bedrooms],
[t0].[ImageURL],
[t0].[Price],
[t0].[Available],
[t0].[Description]
FROM
[dbo].[Homes] AS [t0]
WHERE
([t0].[Description] LIKE @p0) AND
([t0].[Available] = @p1) AND
([t0].[Price] >= @p2) AND ([t0].[Price] <= @p3)
ORDER BY
[t0].[Price] DESC',
N'@p0 nvarchar(4000),@p1 int,@p2 int,@p3 int',
@p0=N'%private%',
@p1=1,
@p2=200000,
@p3=750000
为什么使用sp_executesql?

最佳答案

这种表示法允许运行时编译的TSQL语句与不同的参数一起重复使用。即该语句仅被编译一次,从而提高了效率。

关于sql - 为什么LINQ发送sp_executesql而不是直接执行SQL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1069236/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com