由于某些或其他原因,
Linq2SQL在我的一个表上生成以下内容以进行删除:
DELETE FROM [dbo].[Tag] WHERE ([TagId] = @p0) AND ([Type] = @p1)
-- @p0: Input UniqueIdentifier (Size = 0; Prec = 0; Scale = 0)
[fb538481-562d-45f2-bb33-3296cd7d0b28]
-- @p1: Input TinyInt (Size = 1; Prec = 0; Scale = 0) [1]
-- @p2: Input TinyInt (Size = 1; Prec = 0; Scale = 0) [0]
-- @p3: Input TinyInt (Size = 1; Prec = 0; Scale = 0) [7]
-- @p4: Input TinyInt (Size = 1; Prec = 0; Scale = 0) [5]
-- @p5: Input TinyInt (Size = 1; Prec = 0; Scale = 0) [8]
-- @p6: Input TinyInt (Size = 1; Prec = 0; Scale = 0) [4]
-- @p7: Input TinyInt (Size = 1; Prec = 0; Scale = 0) [3]
-- @p8: Input TinyInt (Size = 1; Prec = 0; Scale = 0) [9]
-- @p9: Input TinyInt (Size = 1; Prec = 0; Scale = 0) [6]
-- @p10: Input TinyInt (Size = 1; Prec = 0; Scale = 0) [1]
-- @p11: Input TinyInt (Size = 1; Prec = 0; Scale = 0) [2]
-- Context: SqlProvider(Sql2008) Model: AttributedMetaModel
Build: 3.5.30729.1
可以看出,前两个参数(@ p0和@ p1)是正确的,但随后它生成一个从0到9的唯一编号的随机集合.
现在这不会以任何方式影响查询/行为,我只对这里发生的事情感兴趣.
更新:
Tag是Linq2SQL继承的基类.额外的参数似乎是所有继承类型的鉴别器(Type)的整数值.如果我删除继承的类型,额外的参数会下降.
更新2:
我注意到SELECT也会发生这种情况.
SELECT
(CASE
WHEN EXISTS(
SELECT NULL AS [EMPTY]
FROM [Tag] AS [t0]
WHERE ([t0].[TagId] = @p0) AND ([t0].[TagType] = @p1)
) THEN 1
ELSE 0
END) AS [value]
-- @p0: Input Guid (Size = 0; Prec = 0; Scale = 0)
[60000000-0000-0000-0000-fe0000000025]
-- @p1: Input Byte (Size = 0; Prec = 0; Scale = 0) [25]
-- @p2: Input Byte (Size = 0; Prec = 0; Scale = 0) [0]
-- @p3: Input Byte (Size = 0; Prec = 0; Scale = 0) [10]
-- @p4: Input Byte (Size = 0; Prec = 0; Scale = 0) [28]
-- @p5: Input Byte (Size = 0; Prec = 0; Scale = 0) [13]
-- @p6: Input Byte (Size = 0; Prec = 0; Scale = 0) [27]
-- @p7: Input Byte (Size = 0; Prec = 0; Scale = 0) [1]
-- @p8: Input Byte (Size = 0; Prec = 0; Scale = 0) [2]
-- @p9: Input Byte (Size = 0; Prec = 0; Scale = 0) [3]
-- @p10: Input Byte (Size = 0; Prec = 0; Scale = 0) [4]
-- @p11: Input Byte (Size = 0; Prec = 0; Scale = 0) [5]
-- @p12: Input Byte (Size = 0; Prec = 0; Scale = 0) [6]
-- @p13: Input Byte (Size = 0; Prec = 0; Scale = 0) [7]
-- @p14: Input Byte (Size = 0; Prec = 0; Scale = 0) [8]
-- @p15: Input Byte (Size = 0; Prec = 0; Scale = 0) [9]
-- @p16: Input Byte (Size = 0; Prec = 0; Scale = 0) [11]
-- @p17: Input Byte (Size = 0; Prec = 0; Scale = 0) [12]
-- @p18: Input Byte (Size = 0; Prec = 0; Scale = 0) [14]
-- @p19: Input Byte (Size = 0; Prec = 0; Scale = 0) [15]
-- @p20: Input Byte (Size = 0; Prec = 0; Scale = 0) [16]
-- @p21: Input Byte (Size = 0; Prec = 0; Scale = 0) [17]
-- @p22: Input Byte (Size = 0; Prec = 0; Scale = 0) [18]
-- @p23: Input Byte (Size = 0; Prec = 0; Scale = 0) [19]
-- @p24: Input Byte (Size = 0; Prec = 0; Scale = 0) [20]
-- @p25: Input Byte (Size = 0; Prec = 0; Scale = 0) [21]
-- @p26: Input Byte (Size = 0; Prec = 0; Scale = 0) [22]
-- @p27: Input Byte (Size = 0; Prec = 0; Scale = 0) [23]
-- @p28: Input Byte (Size = 0; Prec = 0; Scale = 0) [24]
-- @p29: Input Byte (Size = 0; Prec = 0; Scale = 0) [26]
-- Context: SqlProvider(SqlCE) Model: AttributedMetaModel
Build: 3.5.30729.1
请注意.根据MS示例,我使用enum作为鉴别器.
更新3
现在我正在运行一个SQL分析器,我看到以下内容,而且非常令人担忧:(
exec sp_executesql N'SELECT
(CASE
WHEN EXISTS(
SELECT NULL AS [EMPTY]
FROM [Tag] AS [t0]
WHERE ([t0].[TagId] = @p0) AND ([t0].[TagType] = @p1)
) THEN 1
ELSE 0
END) AS [value]',
N'@p0 uniqueidentifier,
@p1 tinyint,
@p2 tinyint,
@p3 tinyint,
@p4 tinyint,
@p5 tinyint,
@p6 tinyint,
@p7 tinyint,
@p8 tinyint,
@p9 tinyint,
@p10 tinyint,
@p11 tinyint,
@p12 tinyint,
@p13 tinyint,
@p14 tinyint,
@p15 tinyint,
@p16 tinyint,
@p17 tinyint,
@p18 tinyint,
@p19 tinyint,
@p20 tinyint,
@p21 tinyint,
@p22 tinyint,
@p23 tinyint,
@p24 tinyint,
@p25 tinyint,
@p26 tinyint,
@p27 tinyint,
@p28 tinyint,
@p29 tinyint,
@p30 tinyint,
@p31 tinyint,
@p32 tinyint',
@p0='60000000-0000-0000-0000-FE0000000025',
@p1=25,@p2=0,@p3=23,@p4=29,@p5=31,@p6=16,@p7=14,@p8=1,@p9=2,
@p10=3,@p11=4,@p12=5,@p13=6,@p14=7,@p15=8,@p16=9,@p17=10,@p18=11,
@p19=12,@p20=13,@p21=22,@p22=15,@p23=17,@p24=18,@p25=19,@p26=20,
@p27=21,@p28=27,@p29=24,@p30=26,@p31=30,@p32=28
谢谢
leppie
最佳答案 这听起来像Linq2Sql中的某个bug.我认为不应该生成额外的参数.
我想你应该在Microsoft Connect上提交一个bug.