Search code examples
c#oracleentity-frameworklinqdotconnect

DotConnect inefficient boolean compare SQL generation


One of my entities has a boolean property. One of the linq queries filters on this property.

context.Items.Where(one => one.BoolProperty == true)

When I look at the generated SQL code, then the query is translated to

... WHERE "Extend1".BOOL_PROPERTY <> 0

This is obviously a problem, as the database does not take the index but makes a full table access.

We are using .Net 4.6, Entity Framework 6, DevArt 8.5 and Oracle 12. The boolean field in Oracle is a Number(1,0)


Solution

  • Please set the following option in your code:

    config.QueryOptions.TrueValueNumber = TrueValueNumber.One;
    

    For more information, refer to https://www.devart.com/dotconnect/oracle/docs/?QueryOptions.html .