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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:11:07+00:00 2026-06-14T08:11:07+00:00

I am trying to filter the results on my query based on whether or

  • 0

I am trying to filter the results on my query based on whether or not they contain the string “baby”.

IEnumerable<ICD.ViewModels.HomeSearchViewModel> query =
                ICDUnitOfWork.AlphaGroups.Find().GroupJoin(ICDUnitOfWork.Alphas.Find(),
                                                           a => a.AlphaGroupID,
                                                           g => g.AlphaGroupID,
                                                           (alphaGroups, alphas) =>
                                                           new ICD.ViewModels.
                                                               HomeSearchViewModel
                                                               {
                                                                   AlphaGroups =
                                                                       alphaGroups,
                                                                   Alphas = alphas
                                                               })
                    .Where(row =>
                           row.AlphaGroups.Title.Contains("baby")
                           || row.Alphas.Any(alpha => alpha.Title.Contains("baby"))
                    );

The problem is that when an Alpha.Title contains the string “baby” it should only show the Alpha’s that contain “baby”, rather than every alpha in the AlphaGroup. If the AlphaGroup.Title contains “baby” it should continue to show each alpha in the group. How can I accomplish this?

  • 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-14T08:11:08+00:00Added an answer on June 14, 2026 at 8:11 am

    You could try something like the following:

    IEnumerable<ICD.ViewModels.HomeSearchViewModel> query =
                    ICDUnitOfWork.AlphaGroups.Find()
                                 .GroupJoin(
                                       ICDUnitOfWork.Alphas.Find()
                                                    .GroupBy(a => new 
                                                                    {
                                                                      BabyIndicator = a.Title.Contains("baby"),
                                                                      GroupID = a.AlphaGroupID
                                                                    }),
                                       a => a.AlphaGroupID,
                                       g => g.Key.GroupID,
                                       (alphaGroups, alphas) =>
                                          new ICD.ViewModels.HomeSearchViewModel()
                                            {
                                              AlphaGroups = alphaGroups,
                                              Alphas = alphaGroups.Title.Contains("baby") ?
                                                alphas.Select(g => g.AsEnumerable()).Aggregate((g1,g2) => g1.Concat(g2)) :
                                                alphas.Aggregate(
                                                (g1,g2) => g1.Key.BabyIndicator ?
                                                           g1 :
                                                           g2).AsEnumerable()
                                            })
    

    Logic:

    The problem is that when an Alpha.Title contains the string “baby” it
    should only show the Alpha’s that contain “baby”, rather than every
    alpha in the AlphaGroup.

    Here we group the alphas by groupID and whether they have babies, we then group join this onto the alphGroups. So we have four possibilities, no groups, one group without baby, one group with only babies and one of each. To pull this all together we aggregate. If there are no groups it returns no groups, if there is one group it returns that group, if there are two groups it returns only the one with babies.

    If the AlphaGroup.Title contains “baby” it should continue to show
    each alpha in the group.

    Here we check whether an alphaGroup has a title baby, if it does return the whole grouping, if not apply alpha title logic

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

Sidebar

Related Questions

Trying to filter the results after a query. Need to find a string inside
I am trying to filter result from JSON string based on status selection. I
I am trying to filter results in an sql query using the like statement.
I am trying to dynamically filter search results. Every result has tags associated with
I am trying to filter a list so it results in a list with
Im trying to filter rows based on a column say c1 that contains boolean
I'm trying to filter a datatable with following code private void Filter(string text) {
I'm trying to do a query to filter on rows from one table and
Im trying to learn class-based views, for a detail or list view is not
I am trying to save a string contains characters whose ordinal is not in

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.