Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Daniel Larsen 116 posts 381 karma points
    Dec 04, 2014 @ 14:33
    Daniel Larsen
    0

    Sort members by more custom properties

    Hi,

    I am trying to sort my members alphabetically by first name and last name, but i can only get it to work with one property. How do I add more?

    @{
        var x = Member.GetAll;  
    
        foreach (var item in x.OrderBy(z => z.getProperty("NameFirst").Value.ToString(), z => z.getProperty("NameLast").Value.ToString())) {
    
            var id = item.Id;
            var first = item.getProperty("NameFirst").Value.ToString();
            var middle = item.getProperty("NameMiddle").Value.ToString();
            var last = item.getProperty("NameLast").Value.ToString();
    
            <li>
                <a href="#@id">@first @middle @last</a>
            </li>
        }       
    }
    

    Thank you for your help! :-)

    /Daniel

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Dec 04, 2014 @ 15:28
    Alex Skrypnyk
    100

    Hi Daniel,

    Did you try to use .ThenBy() ?

          .OrderBy(o => o.InvoiceOwner.LastName)
          .ThenBy(o => o.InvoiceOwner.FirstName)
    

    Thanks

  • Daniel Larsen 116 posts 381 karma points
    Dec 04, 2014 @ 16:32
    Daniel Larsen
    0

    Thank you sir!

    I hope you will have a merry christmas! :-)

    /Daniel

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies