Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

The method 'OrderByDescending' cannot follow the method 'Select' or is not supported. in plugin

Posted on by Microsoft Employee

Hello experts ,

I'am facing the following :The method 'OrderByDescending' cannot follow the method 'Select' or is not supported. Try writing the query in terms of supported methods or call the 'AsEnumerable' or 'ToList' method before calling unsupported methods when using a plugin.

var PrestationPrice = (from pricePrest
in context1.pricePrestSet
where pricePrest.pricelistgroupid == oppProdu.pricelistgroupid &&
pricePrest.hotelid== oppProdu.hotelid
&& (pricePrest.validit_start_date <= oppProdu.start_date.Value.AddDays(1) && pricePrest.rea_validit_end_date >= oppProdu.start_date.Value.AddDays(1))
select new { pricePrest.adultprice, pricePrest.childprice }).OrderByDescending(p => p.adultprice).ThenByDescending(e => e.childprice).ToList();

productPrice = PrestationPrice.First().adultprice.Value;
productPrice = PrestationPrice.First().childprice.Value;

Thank you 

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: The method 'OrderByDescending' cannot follow the method 'Select' or is not supported. in plugin

    Hi Clément,

    I did manage this by adding the order by to my query.

  • Verified answer
    Clem Profile Picture
    Clem 2,541 on at
    RE: The method 'OrderByDescending' cannot follow the method 'Select' or is not supported. in plugin

    Hello,

    As the stack says did you try to perform the following : 

    var PrestationPrice = (Your Query).ToList().OrderByDescending(p => p.adultprice).ThenByDescending(e => e.childprice);

    I think the issue here is that ThenByDescending is just not supported from a IEnumerable variable.


    Clément


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans