Собственно класс
[Table("Tags")]
public class Tag
{
[PrimaryKey, Identity]
public int Id;
[Column]
public string Name;
[Column]
public byte StatusId;
}
CREATE TABLE [dbo].[Tags]
(
[Id] [int] IDENTITY(1,1) PRIMARY KEY
[Name] [varchar](64) NOT NULL,
[StatusId] tinyint NOT NULL
)
При выборке с условием по StatusId
byte statusId = 1;
return db.Where (x=> x.StatusId == statusId).Count();
В SQL фигурирует CONVERT(Int, StatusId)
exec sp_executesql N'SELECT
Count(*) as [cnt]
FROM
[Tags] [t1]
WHERE
Convert(Int, [t1].[StatusId]) = @p1
',N'@p1 int',@p1=1
Собственно в данном случае, на плане запроса MS SQL 2008 R2 это не отражается, но все же, помню времена, что что то подобное приводило к TABLE SCAN.