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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:29:32+00:00 2026-05-15T20:29:32+00:00

We have the following data model: CalendarAppointment 1 <——> * AppointmentRole * <——–> 1

  • 0

We have the following data model:

CalendarAppointment 1 <------> * AppointmentRole * <--------> 1 Person (or Group)

A calendar appointment can have multiple persons associated with it. Each person can be in a different role (attending, driving, picking up or dropping off). (A person can also be a member of a group and groups can be associated with appointments as well, but that’s for extra credit for the purpose of this question).

At the beginning of a web request to render a calendar, we want to pull in all of the appointments relevant to the logged in member for a given date range.

The “driving” table is the Calendar appointment. Rendering looks like:

foreach (var appointment in dataContext.Appointments.Where(person has appointment role)]
{
   ... render appointment ...
   foreach (role)
      ... render role...

Currently, this is being done via LINQ to SQL querying against a view that we’ve defined in SQL Server to join columns from CalendarAppointment, AppointmentRole, and Person. This is the best way to make the query, but once the data is in the object world it would be more convenient to work with objects that map to the constituent tables that make up the view.

So in object world, I want to deal with…

 class CalendarAppointment
 {
     IEnumerable<AppointmentRole> Roles ...

 ...

 class AppointmentRole
 {
    Person Person ...

We’re also running into a related problem with unit tests. It’s much easier to set up a scenario by populating the discrete tables, but then querying against the view. Our in-memory data representation won’t do this for us, so we end up populating an in-memory representation of the view instead.

So what we want to do is query against the view, but then crack” the result into an object structure that mirrors the underlying tables. It seems the only way to do that is to make separate queries against the tables:

  1. Query appointment role table
  2. Query calendar appointments using the set of appointment foreign keys from the first query.
  3. Query person table using the set of person foreign keys from the first query.

This seems pretty convoluted. This seems like it would be a common problem in the ORM world. Does anybody have any insight into either 1) how to perform a query against the view and have it populate table objects on the other side, or 2) a different pattern or approach to the problem?

  • 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-15T20:29:33+00:00Added an answer on May 15, 2026 at 8:29 pm

    Have you looked at AutoMapper?

    AutoMapper uses a fluent configuration API to define an object-object mapping strategy. AutoMapper uses a convention-based matching algorithm to match up source to destination values. Currently, AutoMapper is geared towards model projection scenarios to flatten complex object models to DTOs and other simple objects, whose design is better suited for serialization, communication, messaging, or simply an anti-corruption layer between the domain and application layer.

    I’ve been using this recently to convert LINQ entities into simpler, flatter objects and it’s worked well so far.

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

Sidebar

Related Questions

If I have the following: {hdrs: [Make,Model,Year], data : [ {Make:Honda,Model:Accord,Year:2008} {Make:Toyota,Model:Corolla,Year:2008} {Make:Honda,Model:Pilot,Year:2008}] }
I have the following core data model with two entities: entity item which holds
Consider the following data model: Suppose I have a table called SuperAwesomeData where each
I have the following setup for my Blog Data Model: Blog Articles Categories -----
I have a domain data model which returns a class such as the following:
I have a simple data model of two tables, email and recipients, email can
I have the following data model class defined: @PersistenceCapable public class TestSerializableModelObj { @Persistent(serialized=true,
Hi I have following data in the table: ID-----startDate----endDate 5549 2008-05-01 4712-12-31 5567 2008-04-17
I have the following data structure (a list of lists) [ ['4', '21', '1',
I have a sql table which have the following data, Id City Country ---

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.