Topic
  • 2 replies
  • Latest Post - ‏2018-11-05T17:19:11Z by ShowMeTheAnswer
ShowMeTheAnswer
ShowMeTheAnswer
3 Posts

Pinned topic IBM.EntityFrameworkCore (1.2.2.100) .Take() Linq query does not generate expression tree correctly

‏2018-10-26T19:44:02Z | entityframework expression linq paging parameterization

Hi,

The closest post I can find for the issue I am having is https://www.ibm.com/developerworks/community/forums/html/topic?id=e44f2b21-c361-4cbf-a418-945fec03b8ea, but it has not solved my issue.

 

I am going to sum this up as best I can: 

I have a statement that looks like this - return query.OrderBy(o => o.RegisterId).Take(maxRows).ToList();. While debugging, I can see .Take() is evaluating "maxRows" value as a constant. The first time a query is executed, the generated SQL contains the correct "maxRows" value. If I run the query again, after changing the "maxRows" value, I can see the constant is set to the new value; however, once .ToList() is called, it appears the previous expression tree is retrieved with the old "maxRows" value. The actual SQL that gets generated and sent to the database ends up looking like this: 

SELECT ...
FROM ... AS o
ORDER BY o.REGISTERID FETCH FIRST 3000 ROWS ONLY 

 

The "FETCH FIRST 3000" is supposed to be parameterized like this: "WHERE o.REGISTERID = ", @__maxRows_0", but no matter how many times I change the "maxRows" value, the "FETCH FIRST 3000" constant is always used instead.

 

Can anyone give me insight into whether this is a bug in IBM.EntityFrameworkCore (1.2.2.100) & if there is a fix/workaround?  This has become one of those issues that I have scoured the internet for days with absolutely no mention of anyone else seeing this problem. Thanks for anyone's time!

 

  • RadhikaG
    RadhikaG
    12 Posts
    ACCEPTED ANSWER

    Re: IBM.EntityFrameworkCore (1.2.2.100) .Take() Linq query does not generate expression tree correctly

    ‏2018-11-05T09:12:34Z  

    Hi,

    Seems to be a bug. We will consider addressing this in upcoming releases.

    If it is critical, please open a PMR with IBM to provide a special build.

    Thanks,

    Radhika.

     

  • RadhikaG
    RadhikaG
    12 Posts

    Re: IBM.EntityFrameworkCore (1.2.2.100) .Take() Linq query does not generate expression tree correctly

    ‏2018-11-05T09:12:34Z  

    Hi,

    Seems to be a bug. We will consider addressing this in upcoming releases.

    If it is critical, please open a PMR with IBM to provide a special build.

    Thanks,

    Radhika.

     

  • ShowMeTheAnswer
    ShowMeTheAnswer
    3 Posts

    Re: IBM.EntityFrameworkCore (1.2.2.100) .Take() Linq query does not generate expression tree correctly

    ‏2018-11-05T17:19:11Z  
    • RadhikaG
    • ‏2018-11-05T09:12:34Z

    Hi,

    Seems to be a bug. We will consider addressing this in upcoming releases.

    If it is critical, please open a PMR with IBM to provide a special build.

    Thanks,

    Radhika.

     

    Thanks Radhika,

    I will keep an eye out for a fix.