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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:11:53+00:00 2026-06-07T04:11:53+00:00

When using an EF ObjectContext I see two different extensions methods with the same

  • 0

When using an EF ObjectContext I see two different extensions methods with the same signature as consecutive choices. It doesn’t makes sense to me that there would be some magic that caused one or the other to get called based on which one I picked, so what is actually going on?

enter image description here

  • 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-06-07T04:11:54+00:00Added an answer on June 7, 2026 at 4:11 am

    I’m assuming that Campaigns is an instance of DbSet<Campaign>? DbSet inherits DbQuery, which implements IOrderedQueryable, the definition for which is:

    public interface IOrderedQueryable<out T> : IQueryable<T>, 
        IEnumerable<T>, IOrderedQueryable, IQueryable, IEnumerable
    

    As you can see, both IQueryable<T> and IEnumerable<T> are implemented, but the definition of IQueryable shows that it extends IEnumerable:

    public interface IQueryable : IEnumerable

    So basically, the extension method is implemented for IEnumerable, but it’s also available from IQueryable as it extends the original interface. Intellisense is picking up both of these options because you could end up implicitly or explicitly casting the type to an IEnumerable.

    The method that will actually be run will depend on the type on which it’s called. For example, on your Campaigns instance of DbSet<Campaign> the method will translate it (if you’re using MS SQL) into a SELECT TOP 1... query, but if you’re calling it on Campaigns.ToList(), which is IEnumerable, it’ll return the item at the zero index. The implementation of the extension methods are different for each type.

    Hope that makes sense 🙂

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

Sidebar

Related Questions

I'm using self-tracking entities with EF 4.0 and I see that there's no IsLoaded
I am using ObjectContext.ExecuteStoreQuery to return a list of entities, about 30K. I need
I'm using .NET 3.5 SP1 in ASP.NET MVC application. While using ObjectContext with Http
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
How does one enable the ability to see the full exception using an OData
I have an Entity class that I have extended using the partial class syntax
I'm trying to add a ProfileProperty into the ProfileProperties table using ObjectContext.AddObject . The
I have a question regarding the usage of using statements around ObjectContext objects in
Using ASP.NET 4, and Entity framework 4.3.1 via ObjectContext. Anytime I update/refresh the model
I'm using ADO.NET EF in an MVC application. I'm considering putting the ObjectContext inside

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.