Skip to content

Conversation

@TobiasMarklund
Copy link
Contributor

Expressions where comparisons of enum-of-byte are made are always cast to int comparisons by the C# compiler. This causes SQL queries to do unnecesary casts of tinyint column like CAST ([column] as int)

Counteract that by detecting comparisons of byte enums with other byte enums or int/byte constants and see if they both can be cast to byte.

Fixes #162

Expressions where comparisons of enum-of-byte are made are always cast to int comparisons by the C# compiler. This causes SQL queries to do unnecessary casts of tinyint column like CAST ([column] as int)

Counteract that by detecting comparisons of byte enums with other byte enums or int/byte constants and see if they both can be cast to byte.
@JonathanMagnan JonathanMagnan merged commit 74dce5b into zzzprojects:master Nov 3, 2019
@JonathanMagnan JonathanMagnan self-assigned this Nov 3, 2019
@JonathanMagnan
Copy link
Member

Hello @TobiasMarklund ,

Thank you for your contribution.

The v3.1.1 has been released. It includes your both pull requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Enum-of-byte is unnecessarily cast to int

2 participants