Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7580397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:54:26+00:00 2026-05-30T17:54:26+00:00

I seem to be needing to re-order my result set after i make some

  • 0

I seem to be needing to “re-order” my result set after i make some modifications to it, is this “a feature” if so, some enlightenment? am I missing something?

//need the "IN" type functionality to limit my initial set.
 var resultSet = from t in someContext.SomeEntities
                       .Where("it.some_id IN{" + string.Join(",", array) + "}")
                              where t.obj_id == objtId
                              orderby t.tInt
                              select new customObj
                              {
                                  prop1= t.t1,
                                  prop2 = t.tInt,
                                  prop3 = t.tInt2 
                              };

//Do some other lookups / decision branching and 
//determine that i need to remove the following:

//just for arguments sake
resultSet.ToList().RemoveAll(o => o.prop1== 8 
                    && o.prop1 == 5 
                    && o.prop1 == 11 
                    && o.prop1 == 21); 


foreach (var vals in resultSet)
{
//do something that depends on the order
}

after that sequence.. something that i expected to be in order, is not.. when i do another orderby on the result set like:

foreach (var vals in resultSet.OrderBy(o => o.tInt))
{
   //now the order's okay
}

then it’s what i would’ve originally expected..

so should i not do any ordering until i have filtered my result set down? In this case obviously i could’ve done some filtering on the initial query, but in my situation, i really cant..

..thanks in advance.

UPDATE:

I must be doing a .ToList() on it for the (.RemoveAll()), is that the culprit then?

http://msdn.microsoft.com/en-us/library/wdka673a%28v=vs.90%29.aspx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:54:27+00:00Added an answer on May 30, 2026 at 5:54 pm

    IMO I think you should remove the initial orderby t.tInt and do an order by once you have filtered the list with your line:

    resultSet.ToList().RemoveAll(o => o.prop1== 8 
                        && o.prop1 == 5 
                        && o.prop1 == 11 
                        && o.prop1 == 21);
    

    I have never heard of RemoveAll() changing the order but it is very possible. Either way it will be more efficient to sort fewer records in the long run. I almost always do my sorting after I have filtered things.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seem to be having some issues storing the current date in a core data
I seem to be a little lost on what to so about this, im
I seem to have a problem passing some strings on from one form to
i seem to have some trouble installing autopy.h https://github.com/msanders/autopy/#introduction i already tried the installation
Ok this may seem stupid and I have googled extensively using various different keywords
I seem to be using this sort of pattern in my code a lot
I always seem to battle with this so on my new Windows 7 dev
I have googled but I can't seem to get my script to work. this
I've looked everywhere, but can't seem to find a solution to this problem. I'm
There are lots of similar questions to this, but they all seem to involve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.