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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:17:49+00:00 2026-05-11T15:17:49+00:00

I am fairly new to Linq To SQL but trying to run what should

  • 0

I am fairly new to Linq To SQL but trying to run what should be a fairly simple SQL query and can’t figure out how to make it play nice in LINQ.

SELECT     Users.Id, Users.Id AS Expr1, Users.FirstName, Users.LastName,  User_x_Territory.UserID FROM         Users LEFT OUTER JOIN              User_x_Territory ON User_x_Territory.UserID = Users.Id GROUP BY Users.Id, Users.Id, Users.FirstName, Users.LastName, User_x_Territory.UserID HAVING      (COUNT(User_x_Territory.UserID) = 0) 

Just trying to get all users that do not have a territory assigned, the only way to tell if they have a territory is to check the user_x_territory gerrund.

I am able to get all of the users out of my DB with this:

var users = from u in db.Users             join uXt in db.User_x_Territories on u equals uXt.User into gerr             from users in gerr.DefaultIfEmpty()             select users; 

But from there I can’t figure out how to add a group by/having to refine the search results to only show users with no territories.

Thanks for any help.

  • 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. 2026-05-11T15:17:50+00:00Added an answer on May 11, 2026 at 3:17 pm

    I suggest the following solution.

    db.Users.Where(u => u.User_x_Territories.Count == 0) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to LINQ in general but I've managed to figure things out
I have a fairly long linq query and everything works as it should.. but
I'm fairly new to LINQ and trying to find a more elegant way (other
I'm fairly new to asp.net and especially LINQ and SQL. Say I have a
I'm fairly new to LINQ to SQL, so I could be missing something basic
I am fairly new to using Linq which is turning out a bit tricky
Fairly new to programming. I just can't wrap my head around how to get
Fairly new to Objective C and trying to work within Storyboards given it's the
I fairly new to JQuery and perhaps trying to achieve something that might be
I am fairly new to php and mysql but I have created a small

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.