Directly parameterized literal boolean eq/neq expression found

3 posts, 0 answers
  1. Richard Koslik
    Richard Koslik avatar
    71 posts
    Member since:
    Apr 2010

    Posted 18 Nov 2011 Link to this post

    Hello,
    today i have installed the new Q3 release...now my code does not work anymore (before Q3 it worked!)...

    Following error is thrown:
    An exception occured during the execution of '
    Extent<Web.PORDER>().Where(po => ((((((po.PORDER_S_KEY == value(Klassen.clPRIN+<>c__DisplayClass47).sOrderKey) AndAlso ((Convert(po.PORDER_B_LOCKED) == null) OrElse (Convert(po.PORDER_B_LOCKED) == Convert(0)))) AndAlso ((po.PORDER_D_FROM == Convert(null)) OrElse (po.PORDER_D_FROM < Convert(DateTime.Now)))) AndAlso ((po.PORDER_D_TO == Convert(null)) OrElse (po.PORDER_D_TO > Convert(DateTime.Now.Date)))) AndAlso ((Convert(po.PORDER_B_NIGHT) == Convert(1)) OrElse (value(Klassen.clPRIN+<>c__DisplayClass47).bNightmode == False))) AndAlso value(Klassen.clPRIN+<>c__DisplayClass47).lOrdertypes.Contains(po.PORDER_I_TYPE))).Count()'.
    Failure: Directly parameterized literal boolean eq/neq expression found; use integer type here.

    Linq statement is following:
    lOrdertypes is a List<short?>
    bNightmode is a boolean
      
    var query = from po in iclDB.dbContext.PORDERs
     where po.PORDER_S_KEY == sOrderKey && (po.PORDER_B_LOCKED == null || po.PORDER_B_LOCKED == 0) &&
     (po.PORDER_D_FROM == null || po.PORDER_D_FROM < DateTime.Now) &&
     (po.PORDER_D_TO == null || po.PORDER_D_TO > DateTime.Now.Date) &&
     (po.PORDER_B_NIGHT == 1 || bNightmode == false) &&
     lOrdertypes.Contains(po.PORDER_I_TYPE)
    select po;
      
    if (query.Count() == 0) return "NOT_FOUND"; // order not found!

    Why and where should i use a integer???!!!

    regards
    Richard.

  2. Richard Koslik
    Richard Koslik avatar
    71 posts
    Member since:
    Apr 2010

    Posted 18 Nov 2011 Link to this post

    Hello,

    the problem is the boolean variable in the linq statement.
    If it is changed to

        
        (po.PORDER_B_NIGHT == 1 ||

     

    Convert.ToInt32(bNightmode) == 0) &&

    the statement works.
    But it can't be the solution to convert each used boolean variable to an integer...

    regards
    Richard.

     

  3. DevCraft banner
  4. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 18 Nov 2011 Link to this post

    Hello Richard Koslik,

    I'm really sorry  about this regression. I can reproduce this here now. Our parameter detection is improved and the fixed condition is detected as literal, and generates the mentioned exception. I will try to fix this.
    In the mean time you can do one of the following:
    (a) Push the condition conditionally to the server: Either it is night mode, then generate one kind of query, or it is not night mode, then generate another kind of query. You can combine LINQ expressions.
    (b) Use !bNightMode instead of bNightMode == false. The effect is the same, however the LINQ tree is slightly different and therefore the conditions are pushed to the server slightly different.

    Again, my apologies for this regression. I've included dozens of tests for booleans for the release, but this form did not make it.

    I've updated your Telerik points.
    Regards,
    Thomas
    the Telerik team

    NEW and UPDATED OpenAccess ORM Resources. Check them out!

Back to Top