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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:39:41+00:00 2026-06-17T05:39:41+00:00

I have two entities Candidate and CandidateLocation where a Candidate can have multiple CandidateLocation

  • 0

I have two entities Candidate and CandidateLocation where a Candidate can have multiple CandidateLocation entries.

A CandidateLocation contains the CandidateId, an ISO Country Code (e.g. US, GB) and a type column (1 = Permitted, 2 = Restricted).

Rules dictate that if the Candidate does not have any ‘Permitted’ entries in the CandidateLocation table they can work anywhere. If they have an explicit ‘Permitted’ location they can only work in the explicitly permitted locations. They can not work in explicilty restricted locations.

To try an demonstrate this please see the image below (Candidates can have multiple locations I have kept it to one to simplify the illustration)

Rules

In SQL one way of achieving this would be the following query

SELECT  *
FROM    Candidate
WHERE   Candidate.IsArchived = 0
    AND
        -- Do not inlude restricted locations (RestrictionStatus = 2)
        Candidate.CandidateId NOT IN (SELECT CandidateId FROM CandidateLocation WHERE IsArchived = 0 AND CountryISOCode = @Location AND RestrictionStatus = 2)
    AND
        (
        -- Include Explicit Permitted Locations
        Candidate.CandidateId IN (SELECT CandidateId FROM CandidateLocation WHERE IsArchived = 0 AND CountryISOCode = @Location AND RestrictionStatus = 1)
        OR
        -- Include Candidates with no Explicit Permitted Locations
        Candidate.CandidateId NOT IN (SELECT CandidateId FROM CandidateLocation WHERE IsArchived = 0 AND RestrictionStatus = 1)
        )

If anyone knows how to achieve this using linq & Navigation Properties I would greatly appreciate the help.

Many thanks

  • 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-17T05:39:42+00:00Added an answer on June 17, 2026 at 5:39 am

    Assuming you’ve got one-to-many association between Candidates and CandidateLocations

    Context.Candidates.Where(c => c.IsArchived == 0 &&
    !c.CandidateLocations.Any(
        l => l.CountryISOCode == location && l.RestrictionStatus == 2) &&
    (c.CandidateLocations.Any(
        l => l.CountryISOCode == location && l.RestrictionStatus == 1) ||
    !c.CandidateLocations.Any(
        l => l.RestrictionStatus == 1))
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two entities types: RunContainer parent entity type Run child entity type Run
I have two entities. Groups. Pools. A Group can create many pools. So I
imagine I have two entities - Tag and Text where Text has multiple tags
I have two entities, EntityA and EntityB. EntityB can optionally be related to EntityA,
I have two entities ( Dataset and Item ), where the first one contains
I have two entities, User and UserPermission. The User entity contains all your normal
I have two entities User and Course. A user can take several courses which
I have two entities one is Event and another is User. User can like
I have two entities, Users and Books with a has_and_belongs_to_many relationship. How can I
I have two entities Group and Contact. A contact can belong to many groups,

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.