Queries like ```csharp session.Query.All<SomeType>().Where(e => e.State == States.New) ``` have following filter in SQL if ```States``` has base type smaller than ```integer```, e.g. ```byte``` ```sql SELECT [a].[Id], 100 AS [TypeId], [a].[State] FROM [dbo].[SomeType] WHERE (CAST([a].[State] AS integer) = 1) ``` Such SQL queries have poor performance even if ```State``` is indexed. This happens because C# compiler elevates left and right expressions up to ```int```. We could improve this case by applying cast to actual underlying type of ```enum```. Note that the problem is also appears in filtered indexes.