Hi
For some or other reason Linq2SQL generates the following on 1 of my tables for a delete:
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
As one can see, the first 2 parameters (@p0 and @p1) are correct, but then it generates a randomized set of the unique number from 0 to 9.
Now this does not affect the query/behaviour in any way, I am just interested in whats going on here.
UPDATE:
Tag is a base class for Linq2SQL inheritence. It seems the extra parameters are the integer values of the discriminator (Type) of all the inherited types. If I remove inherited types, the extra parameters goes down.
UPDATE 2:
I have noticed this happens for SELECT's too.
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
Just to note. I am using an enum for the discriminator, as per the MS examples.
UPDATE 3
Now I am running a SQL profiler, and I am seeing the following, and it's pretty worrying :(
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
Thanks
leppie