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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:08:30+00:00 2026-06-07T01:08:30+00:00

I am using a two LINQ queries(nested) Here’s what I want my query to

  • 0

I am using a two LINQ queries(nested)

Here’s what I want my query to achieve:

In my inner query

  • Retrieve a collection of UserLocation objects using two conditions

In my outer query

  • Retrieve a filtered collection of User objects where User.UID matches the property UserLocation.UID of each UserLocation object from the collection in the inner query.

I’m almost there code-wise, I’m just missing the final step — I don’t know how to get the outer query to enumerate through the UserLocation collection and match the UID.

In my code I have two queries, the top one is a working example of getting the FullName property of a User object using the inner query and the conditions I need(as well as matching UID).

The second query is the one I am having trouble with. What am I missing?

            ownerLiteral.Text = 
            Users.First(u => u.UID.Equals(
                UserLocations.First(s => s.IsOwner == true && s.LID.Equals(building.LID)).UID)).FullName;

        var propertyteam = 
            Users.Where(c => c.UID.Equals(
                UserLocations.Where(x => x.IsPropertyTeam == true && x.LID.Equals(building.LID))));

Edit: Fixed the problem

I had forgotten that UserLocations was a member of Users — I shortened down my query and used .Any to select the UserLocations members that fit my conditions, then just return the User.

In the first query I return the FullName for the User object.

In the second query I now return a collection of User objects that fit the conditions.

For those that are interested I bind the second query to a DataList and then evaluate for their FullName in the user control.

ownerLiteral.Text = 
            Users.First(
            u => u.UserLocations.Any(
                ul => ul.IsOwner == true && ul.LID.Equals(building.LID))).FullName;

var propertyteam = 
            Users.Where(
            u => u.UserLocations.Any(
                ul => ul.IsPropertyTeam && ul.LID.Equals(building.LID)));
  • 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-07T01:08:32+00:00Added an answer on June 7, 2026 at 1:08 am

    Your class relationships are confusing me, but I think your problem is that you’re trying to treat a collection of UserLocation objects (Where() returns an IEnumerable) as a single UserLocation

    I think this might do it:

    var propertyteam = LoggedInUser.ExtranetUser.Company.Users
      .Where(c => c.UID.IsPropertyTeam == true && c.UID.LID.Equals(building.LID));
    

    Edit, based on further information:

    So maybe this is what you’re looking for?

    var uidsWhoArePartOfThePropertyTeamForThisBuilding
      = UserLocations.Where(x => x.IsPropertyTeam && x.LID == building.LID)
      .Select(x => x.UID);
    

    Assuming the UID member of a UserLocation is a whole User object, and not just some int ID for a User.

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

Sidebar

Related Questions

I'm using a linq group by query (with two grouping parameters) and would like
How can I join the two queries using LINQ to EF? I need the
I have two queries very similars, using the Linq ExecuteQuery method the first take
I've written two LINQ queries using the join method. Essentially, if I switch the
I want to order a DataTable with Linq to DataSet using two ordering values.
Can i join two tables using LINQ for NHibernate like I can do in
I am using VB.NET with LINQ to MS SQL. I have two following tables.
Using LINQ to XML, XElements and XAttributes I'd like to filter a query using
Is it possible to using paging functionality in Linq queries? Let's say I have
I have two queries in my RIA DomainService. one is a simple get using

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.