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

  • Home
  • SEARCH
  • 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

I'm new to using LINQ to Entities (or Entity Framework whatever they're calling it)
I'm confused about Linq to Entities. Is it the new name of Entity Framework
I'm planning to use MS entity framework for new web apps (come on EF
I am very new to the entity framework, so please bear with me... How
I am trying to create a new contact using Dynamic Entity. The sample i
I'm getting ready to start a new project and I've been researching the entity
New to javascript/jquery and having a hard time with using this or $(this) to
New class is a subclass of the original object It needs to be php4
New to xml. Looking for XPath to search a xml file with python ElementTree
New to silverlight. Traditionally if I were to design a wizard-like process where 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.