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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:19:51+00:00 2026-06-01T04:19:51+00:00

Given EF entities defined as follows class Person { int PersonID; string Name; string

  • 0

Given EF entities defined as follows

class Person { int PersonID; string Name; string Title; }
class ContactType { int TypeID; string TypeString; } // phone # types - mobile, home, work etc.
class PersonContact { int PersonID, int ContactTypeID, string ContactText; bool IsDefault; }

Where a person can have multiple phone #’s and even multiple mobile #’s

Looking for ways to display all Persons in a table structure as follows

PersonID, Name, Title, PrimaryContact, MobileNumber

Where PrimaryContact is the PersonContact Record with IsDefault = true

and

WHERE MobileNumber is “A” PersonContact Record with PersonContact.ContactType = ContactType.TypeID and ContactType.TypeString = “Mobile”

NOTE –

PrimaryContact is a lookup into PersonContact

MobileNumber is ALSO a lookup into PersonContact

They could point to the same PersonContact record or could be different depending on IsDefault = true

ALSO There could be multiple “Mobile” PersonContact records for a person

  • 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-06-01T04:19:52+00:00Added an answer on June 1, 2026 at 4:19 am

    Try this below.

    var result = ctx.Persons
    .Select(x => 
    new {PersonID = x.PersonID, 
         Name = x.Name,
         Title = x.Title,
         PrimaryContact = x.PersonContacts.FirstOrDefault(y => y.IsDefault == true).Select(t => t.ContactText),
         MobileNumber = x.PersonContacts.FirstOrDefault(z => z.ContactType.TypeString =="Mobile").Select(q => q.ContactText)
         }).ToList();
    

    Sadly i think this might result in a select n + 1 type query 🙁

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

Sidebar

Related Questions

Consider the following Entities. public class Product{ int id; Date effectiveDate; Date expiryDate; Set<Inventory>
Given the following two entities : class Parent { @OneToMany(cascade=CascadeType.ALL) private Set<Child> children; (...)
Given JPA annotated Entities, is it possible to generate (i.e. before runtime) the list
Given a small set of entities (say, 10 or fewer) to insert, delete, or
Given a DateTime representing a person's birthday, how do I calculate their age in
So I've got an .xcdatamodel with about a dozen Entities defined and related to
I use Hyperjaxb3 to generate JPA entities from XSD schema. I have a xsd:string
I need to retrieve a list of given entities (apples) from another resource (fruitDelaer)
Given the following entity definitions: @Entity class abstract A { Collection<A> parents; } @Entity
I have the following model: public class Blog { public int BlogID { get;

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.