SqlExpression not being parsed correctly

I have select statements such as the following:

x => x.DeviceId == id && !x.IsDeleted && x.Environment == (byte)env

In the above example, the variable env is an enum which is mapped to a tinyint in the database.

I have just updated to the latest version of ServiceStack (4.5.0) and am using the SqlServer2012Dialect and the above is not working correctly. I remember I made a pull request to the old v3 that would allow the interpretation of the above statement into correct SQL.

Now OrmLite does not convert the env variable into a byte, but tries to use the ToString representation of the enum. This then throws a SQLException that says "Conversion failed when converting the nvarchar value ‘…’ to data type tinyint’.

Has something changed?

Can you submit an issue showing a stand-alone repro to: https://github.com/ServiceStack/Issues

Note: in OrmLite enums need to annotated with [Flags] or [EnumAsInt] to be treated as an integer.