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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:51:32+00:00 2026-05-25T05:51:32+00:00

I have a MembershipGroups table that is associated with a child Members table. The

  • 0

I have a MembershipGroups table that is associated with a child Members table. The Members table has a Status column which can be set to Active or Inactive.

I want to select all MembershipGroups and only their active Members

As an example,

MembershipGroups

ID—-Title

1—–Group #1

2—–Group #2

Members

MembershipGroupID-Name–Status

1————————-John—-Active

1————————-Sally—-Inactive

1————————-David—Inactive

I’m trying to create a query that looks something like the following (which doesn’t currently work):

var query = from mg in db.MembershipGroups
where mg.Members.Status = "Active"
select mg

The result for this example should return a MembershipGroup of ID#1 with only one child Member entity

How can use LINQ-to-SQL to select a parent object that filters on child objects? If I were using straight T-SQL then this would be a simple join with a where clause but it seems to be much more difficult to do using LINQ-to-SQL.

  • 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-25T05:51:33+00:00Added an answer on May 25, 2026 at 5:51 am

    Edit – Updated answer to return the MemberShipGroup object

    var query = (from mg in db.MembershipGroups
                join m in db.Members.Where(mem => mem.Status == "Active")
                on mg.ID equals m.MembershipGroups into members
                select new
                {
                   MembershipGroup = mg,
                   Members = members
                }).AsEnumerable()
                  .Select(m => new MembershipGroup  
                               {
                                 ID = m.MembershipGroup.ID,
                                 Title = m.MembershipGroup.Title,
                                 Members = m.Members 
                               });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a linking (or ref) table which has a dual primary key. Need to
Have an app that can use tts to read text messages. It can also
Have just started using Visual Studio Professional's built-in unit testing features, which as I
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:
Have a bunch of WCF REST services hosted on Azure that access a SQL
Have a look at one of my websites: moskah.com The problem is that it
Have a simple contact us XPage created. Have server side validation in place that
Have a really weird one here. The app has two targets, just to be
Have a problem that seems easy on paper but i'm having a big problem
Have the following cronjob set up in root's crontab: (centos 5.x) 2 * *

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.