Linq to SQL Int16 get converted as Int32 to SQL command
With method parameter
Int16? id
And the Linq to SQL where where clause
where !id.HasValue || m.Id == id
Received command text for condition in data context
From the renderer:
SELECT [t0].[Id], [t0].[Name], [t0].[IsActive]
FROM [Model] AS [t0]
WHERE (CONVERT(Int,[t0].[Id])) = @p0
-------------------------------
@p0 [Int32]: 5
My mapped class has id as Int16 and the database itself has column type as small, so why behind the scenes does sql think this parameter is an integer (Int32) and not a small (Int16)?
Column display:
[Column(IsPrimaryKey = true, DbType="SmallInt NOT NULL", CanBeNull=false)]
public Int16 Id { get; set; }
+2
source to share
2 answers