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 585719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:01:56+00:00 2026-05-13T15:01:56+00:00

I have an object which has a property that contains an IEnumerable of objects.

  • 0

I have an object which has a property that contains an IEnumerable of objects. Each object in the IEnumerable has a property that is also an IEnumerable. I am attempting to capture a larger list of the inner property. Unfortunately, the lambda expression that I am using is returning an OrderedEnumerable. I’d like to just retrieve a simple IEnumerable.

public class OrgForm
{
    public string OrgNum { get; set; }

    public IEnumerable<CustomerForm> CustomerFormList
    {
        get
        {
            var list = from cf in OrgCustomerList
                       where cf.Customer.AssignedOrg == OrgNum
                       select cf;

            return list;
        }
    }
}

Use of CustomerFormList

OrgForm of = new OrgForm();
IEnumerable<Machine> machines = of.CustomerFormList
                                  .Select(cf => cf.ActiveMachines);

Edit

So after prompting from Jon Skeet and Mark Byers I looked a little deeper and found that ActiveMachines had been modified to perform an OrderBy so now the return of an OrderedEnumerable makes sense (my bad for not reading code set change comments).

public class CustomerForm
{
    public IEnumerable<Machine> ActiveMachines
    {
        get
        {
            var active = Customer.MachineList.ToList()
                .Where(m => "a".Equals(m.MachineStatus)
                            && !m.ToReapp);

            return active.OrderBy(m => m.MachineCategory);
        }
    }
}

This is great except machines doesn’t allow me to write something like this as it sees each item in machines as an enumerable based on the category.

foreach (KeyValuePair<int, string[]> kvp in trueUpPt)
{
    Machine machine = cf.ActiveMachines
        .First(m => m.MachineSk == kvp.Key);
    machine.MachineLicenseBillback.ProjectNum = kvp.Value[0];
    machine.MachineLicenseBillback.TaskNum = kvp.Value[1];
}
  • 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-13T15:01:56+00:00Added an answer on May 13, 2026 at 3:01 pm

    OrderedEnumerable<T> is an IEnumerable<T> – it’s one particular implementation. Obviously you’ve got to return some implementation (or null) – it’s not going to be an instance of the interface directly.

    The code you’ve presented should be fine as it is. It’s declared to return IEnumerable<T> so it shouldn’t make any difference unless you cast the result. Having said that, the property you’ve shown shouldn’t be returning an OrderedEnumerable anyway… Enumerable.Where just returns a new iterator. Admittedly it won’t change the order so you could have an overload for Where(this IOrderedEnumerable<T>) but I don’t believe there’s one in the standard library.

    What problem is this actually causing you, and are you using some extra libraries? If you could come up with a short but complete example it would really help.

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

Sidebar

Related Questions

I have an Asset object that has a property AssignedSoftware, which is a collection.
I have a Request object which contains a list of Approvers. An approver has
I have object A which in turn has a property of type Object B
I have a strongly typed list of custom objects, MyObject , which has a
So I have an object which has some fields, doesn't really matter what. I
I have a parent object which has a one to many relationship with an
I have a cache which has soft references to the cached objects. I am
I have a business object, which is a composite of child objects. I am
I have a list of objects, of which I cannot know the type of
Say I have a Dictionary object which contains many instances of an object called

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.