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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:48:16+00:00 2026-05-18T05:48:16+00:00

New to Entity Framework .Using EF4. I have found articles and managed to use

  • 0

New to Entity Framework .Using EF4. I have found articles and managed to use stored procedures to return a list of entities.

But cannot see/work out how you return a single entity.

Given that I have a stored procedure “GetCustomerById” that return a single customer How do I map it?

Using the Model Browser I right click on “Function Import” and I have added my StoredProcedure
however whatever I select does not seem to return a “Single Entity”

Am I missing the obvious?

thanks a lot for any link or suggestions

  • 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-18T05:48:17+00:00Added an answer on May 18, 2026 at 5:48 am

    When you do Function Import you need to select the entity your SP returns from the drop down (i.e. Customer). The catch is EF does NOT directly returns Customer object as per your selection but System.Data.Objects.ObjectResult which implements IEnumerable.
    To be more specific, here is the generated code for your function:

    public ObjectResult<Customer> GetCustomerById(Nullable<global::System.Int32> Id)
    

    That’s because EF has no idea if your SP returns a single record or a list of them so it wraps the result inside ObjectResult. You can enumerate through this to get your Customer entity like any other IEnumerable object. For example:

    Customer myCustomer = context.GetCustomerById(1).First();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New to Entity framework. I am using EF4 and I have implemented for now
I'm new to Entity Framework and am using Database First. I have inherited a
I have created a new application using Entity Framework 4.3 database migrations. The migrations
Using Entity Framework 4 with stored procedures and SQL Server 2008 SP1... When running
I am using Entity Framework 4 with the Service/Repository/EF4/POCO classes technique, and I have
iam new to Entity framework i have learned about using SP and how to
I am creating a new database model using Entity Framework 4.3 Code-FIrst; using Fluent
I am writing a new application using the Entity Framework. Where would the EF
When adding a new Entity Framework object to a database, how could one have
Possible Duplicate: Entity Framework with NOLOCK I'm using EF4 and .Net 4 to load

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.