Skip to content

Unnecessary cast in sql with Linq are causing performance issues #2490

Closed
@gokhanabatay

Description

@gokhanabatay

Hi,
With NH 5.3.2 update Equals method is not working with linq throws "System.NotSupportedException : Boolean Equals(System.Object)" exception.
So we changed to == operator but if field is nullable short its now adding extra cast in sql, earlier it was not with Equals method as expected.

https://github.com/gokhanabatay/NHibernateBugTest/blob/master/NHibernateBugTest/CustomTypeSelectFailsTest.cs
Test Case:
NullableShortFieldIsNullConditionTest

select customer0_.GUID as guid1_1_, customer0_.NAME as name2_1_ from CUSTOMER customer0_ where exists (select addresses1_.GUID from ADDRESS addresses1_ where customer0_.GUID=addresses1_.CUSTOMER_GUID and cast(addresses1_.ADDRESS_TYPE as int4)=?)

v5.2 working as expected test case: NullableShortFieldIsNullConditionTestV5_2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions