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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:22:09+00:00 2026-05-22T23:22:09+00:00

I’ve got a problem I’ve been going round and round on, and every time

  • 0

I’ve got a problem I’ve been going round and round on, and every time I think I have a solution I seem to come back to a core requirement not being fulfilled (I will detail this later).

What I’m trying to do, at a simplistic level, is to return a collection of objects from data supplied by a stored procedure. The object hierarchy is a follows

Shipment Object – this has a ShipmentNumber string property and a List collection

OrderHeader Object – this has OrderNumber double, OrderType string, ShipmentNumber string properties and a List collection

OrderLine Object – this had OrderNumber double, OrderType string, OrderLine double, ItemNumber string properties

Shipment <-> OrderHeader is a 1 to many based on ShipmentNumber on either object

OrderNumber <-> OrderLine is a 1 to many based on OrderNumber and OrderType on either object

This object structure visualises how I need to view my data for a particular report (it’s actually a lot more complex than this, but this is a simple example I am initially trying to get working) and bears no resemblence to my database table structure. I am trying to map data from a stored procedure into this structure so that I end up with a collection of shipments, which then have a collection of order headers within them and these have a collection of lines within them, but I don’t seem to be able to do this. I can’t seem to do it with LINQ so I am looking at the Entity Framework. It seems that you can set an SP to return several SELECT outputs and then use the ObjectContext.Translate<…>(…) method to map data into objects, like this, and then the Translate method will take care of applying the associations, but when I trying this I’m getting an error reporting that the entity object properties aren’t mapped. Looking into this mapping it seems to come back to the objects having to refer to actual database tables (this is my recurring problem).

How, if it is possible, can I load this data, from a stored procedure(s), into this structure of objects using LINQ, EF, or something else without having to base my classes on database tables? Surely this is possible? I can do this with a single collection of objects, but the problem seems to come when these objects contain collections of other objects.

Just a few background points:- I have to use stored procedures to get the data – this is out of my control and won’t change. The tables concerned are spread across several database servers, some of which the web server physically doesn’t have access to, but the database server it does have access to has cross-server querying access to all the servers (hence another reason to use SPs as, AFAIK, LINQ, etc can’t do cross-server joins) so if I do pull table definitions from my development environment (where, obviously, I do have access to all the tables) these won’t be accessible in the production environment.

I could either create a flattened dataset of all the data then read through it, manually detecting the grouping changes (Shipment Number, OrderNumber) and then write my code accordingly, but then this doesn’t make use of OOP and seems a large step backwards, plus it doesn’t supply a reusable object for other, future, requirements. Instead, I could write code to go through the datasets and load the data manually into these objects but I figure why reinvent the wheel – surely this isn’t an unusual requirement and there must be a way to do this?

Thanks – MH

  • 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-22T23:22:09+00:00Added an answer on May 22, 2026 at 11:22 pm

    How, if it is possible, can I load
    this data, from a stored procedure(s),
    into this structure of objects using
    LINQ, EF, or something else without
    having to base my classes on database
    tables?

    Do I understand correctly that you want stored procedure to materialize result set for you and make connection among objects without mapping objects in entity data model? In such case the answer is no, it is not possible.

    The Translate method uses mapping information so it cannot translate result sets into custom information. Automatic wiring of related objects works only if objects are tracked by the context => they must be mapped entities.

    Default stored procedure mapping in EF can use only flatten hierarchy where columns from result set are mapped to properties in target objects. EF doesn’t natively support stored procedures returning multiple result sets (Linq-to-sql does) but you can use EFExtensions to have this support (but it is more like using native ADO.NET).

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

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.