locked
This overload of the method 'System.Linq.Queryable.TakeLast' is currently not supported RRS feed

  • Question

  • User-1142747527 posted

    I have an ASP .Net Core 2.2 Web API using Entity Framework Core. It connects to a MySQL database using the latest version of Pomelo. When I try to execute the Linq function "TakeLast", like this:

    var messages = dbContext.Messages
    .TakeLast(5)
    .ToList();
    I get this error:

    Exception thrown: 'System.NotSupportedException' in Remotion.Linq.dll

    System.NotSupportedException: Could not parse expression 'value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[PropWorx.API.Models.Message]).TakeLast(__p_0)': This overload of the method 'System.Linq.Queryable.TakeLast' is currently not supported.

    The Ling function "Take" works - but "TakeLast" doesn't. Is this a limitation of MySql? Or Pomelo? Any workaround?

    Thanks

    Friday, June 28, 2019 2:29 PM

Answers

  • User1520731567 posted

    Hi f.a.rodriguez,

    According to your desacriptions,it seems that TakeLast not works in Pomelo. 

    Pomelo has not yet started supporting 'System.Linq.Queryable.TakeLast'.

    If you TakeLast the data which has been sort ,I suggest you could use take() and OrderByDescending() to achieve the same goal.

    For example:

    var messages = dbContext.Messages.OrderByDescending(s=>s).Take(5).ToList();

    Like the picture,you could get the same result with below two ways:

    Best Regards.

    Yuki Tao

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 1, 2019 2:43 AM

All replies

  • User1520731567 posted

    Hi f.a.rodriguez,

    According to your desacriptions,it seems that TakeLast not works in Pomelo. 

    Pomelo has not yet started supporting 'System.Linq.Queryable.TakeLast'.

    If you TakeLast the data which has been sort ,I suggest you could use take() and OrderByDescending() to achieve the same goal.

    For example:

    var messages = dbContext.Messages.OrderByDescending(s=>s).Take(5).ToList();

    Like the picture,you could get the same result with below two ways:

    Best Regards.

    Yuki Tao

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 1, 2019 2:43 AM
  • User-1142747527 posted

    Thank you!!!

    Monday, July 1, 2019 1:04 PM