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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:45:49+00:00 2026-05-22T02:45:49+00:00

To select all Scheduling s which are active, I have the following code: var

  • 0

To select all Schedulings which are active, I have the following code:

var allSchedulesOnALine = CurrentUser.Lines.SelectMany(o => o.Scheduling).Where(o => o.Active);
var allSchedulesUnscheduled = Entities.SchedulingSet
    .Where(o => o.Line == null && o.Site.Id == CurrentUser.Site.Id &&
           o.Factory == CurrentUser.Factory && o.Active);

IEnumerable<Scheduling> allSchedules = allSchedulesUnscheduled.Union(allSchedulesOnALine);
foreach(Scheduling schedule in allSchedules.OrderBy(o => o.Ordering))
{
    //Do Stuff
}

(Factory is an int)

When I run this code, I get this cryptic error on the foreach line:

Unable to create a constant value of type ‘System.Collections.Generic.IEnumerable`1’. Only primitive types (‘such as Int32, String, and Guid’) are supported in this context.

Strangely enough, I can enumerate both allSchedulesOnALine and allSchedulesUnscheduled separately. Even stranger, if I reorder the union:

IEnumerable<Scheduling> allSchedules = allSchedulesOnALine.Union(allSchedulesUnscheduled);

It works fine!

Does anyone have any idea why this would happen? Am I missing something crucial, or is this a bug?

I should mention I am using Entity Framework 3.5. EF4 is not an option for us currently – it is beyond my control :\

  • 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-22T02:45:50+00:00Added an answer on May 22, 2026 at 2:45 am

    You’re calling two different methods with your “reordering”.

    You don’t show the types of allSchedulesOnALine or allSchedulesUnscheduled, but I’m betting allSchedulesOnALine is of type IEnumerable<Schedule> and allSchedulesUnscheduled is of type IQueryable<Schedule>.

    So when you call Queryable.Union, you’re asking the EF to translate the expression into SQL. But the argument you pass is of type IEnumerable<Schedule>, and it can’t translate that into a query.

    On the other hand, when you call Enumerable.Union, you’re asking LINQ to Objects to do the whole thing in memory, which works fine, albeit perhaps slower.

    So the reason the behavior is different is that you’re calling two completely different methods, which do different things, but happen to have the same name. No, it’s not a bug.

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

Sidebar

Related Questions

Hi how would I select all link when they have the following id. <a
I have to select all fields which contain a specific text and ended with
Select all records, ID which is not in the list How to make like
I can select all the distinct values in a column in the following ways:
I'd like to select all rows from one table which match one or more
I'm trying to select all text in-between following a specific pattern: Sample Text: by
I want to select all the select elements that have a value of -1
I am trying to select all rows that have helloworld in category column. Here
I have a checkbox select all issue. I have multiple checkbox that can be
How can I select all data from GridView s current row.. I have a

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.