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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:27:26+00:00 2026-05-13T14:27:26+00:00

I have a stored procedure that returns a collection of my entity class objects.

  • 0

I have a stored procedure that returns a collection of my entity class objects. Since I want my navigation properties populated as well I’m using EF Extensions and I’ve written my own Materializer class.

But. My entity class has a navigation property of Type that points to a different entity. Stored procedure of course returns an ID from the lookup table (foreign key).

I would like to populate my types as if I was eagerly loading a related entity. How do I do that in my Materializer? Can I do it without having a stored procedure that returns two result sets?

I would like to implement something similar to what Include() extension method does on source selection in LINQ statement.

  • 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-13T14:27:27+00:00Added an answer on May 13, 2026 at 2:27 pm

    I’ve solved this myself some time ago. I’m just answering my own question if anyone else would need it.

    So what kind of results should stored procedures return? It hugely depends on relation type. Lets say we have two tables: TableOne and TableTwo.

    1:0..1 relation

    In this case stored procedure should return both at once:

    select t1.*, t2.*
    from TableOne t1
        [left] join TableTwo t2
        on t2.key = t1.key
    

    When they are 1:1, you can easily omit left.

    1:MANY relation

    In this case it’s much easier to write stored procedures that return more results. Starting from those at side one so they will be prepared when you bind the many side table.

    /* relation one */
    select *
    from TableOne
    /* relation many */
    select *
    from TableTwo
    

    But if you would still like to return a single result set, you should check for each record whether you already have a certain entity loaded. There’s a method called FindOrAttach() that can help you. So each result will return both entities and you have to chech if they are loaded. If they are not, materialize… But as mentioned: it’s much easier to return two result sets.

    MANY:MANY relation

    You should also write your stored procedure to return more results. In this case 3 of them.

    /* first table */
    select *
    from TableOne
    /* second table */
    select *
    from TableTwo
    /* relation *:* */
    select *
    from TableOne2Table2
    

    Materilize first two tables as usual and then call Attach for each record from thirs result loading by keys from TableOne and TableTwo. This will also populate entity set navigation properties.

    I home this will help others as it helped me.

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

Sidebar

Related Questions

No related questions found

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.