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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:49:51+00:00 2026-06-15T20:49:51+00:00

probably someone can help me with this (at least for me) complicated problem. Lets

  • 0

probably someone can help me with this (at least for me) complicated problem.

Lets say i have the following data (in DB)

Tab1 (id_t1): Item
  (1)
  (2)
  (3)

Tab2 (id_t2, id_t1): Group
  (4, 1)
  (5, 1)
  (6, 2)
  (7, 3)

Tab3 (id_t3, id_t2, v): GroupField
  (10, 4, 100) 
  (11, 4, 300)
  (12, 5, 200)
  (13, 6, 100)
  (14, 6, 200)  
  (15, 7, 100)
  (16, 7, 300)

Now i’d like to select all Items that include all of some specific GroupFields.

Eg. i have v = list(100,200)

and i like to get back 1,2 but not 3

1 because Group4 holds the Field10 with v=100 and Group5 holds Field12 with v=200

and 2 because Group6 holds Field13 with v=100 and Field14 with v=200

Is something like this possible in Linq? (i allready tried different ways (any/all) but without success so far.

I don’t get the point how to overcome that “field can be in any Group and not all in one Group”…

I don’t even know how to do this in SQL in one command without using temp-tables/cursors.

_rene

  • 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-15T20:49:52+00:00Added an answer on June 15, 2026 at 8:49 pm

    Try this:

    var result =
        groups.Join(fields, o => o.Id, i => i.GroupId,
                    (o, i) => new { Group = o, Field = i } )
              .GroupBy(x => x.Group.ItemId)
              .Where(x => values.All(y => x.Any(z => z.Field.Value == y)))
              .Select(x => x.Key)
              .Distinct();
    

    The following classes are used:

    class Group
    {
        public Group(int id, int itemId)
        {
            Id = id;
            ItemId = itemId;
        }
    
        public int Id { get; set; }
        public int ItemId { get; set; }
    }
    
    class GroupField
    {
        public GroupField(int id, int groupId, int value)
        {
            Id = id;
            GroupId = groupId;
            Value = value;
        }
    
        public int Id { get; set; }
        public int GroupId { get; set; }
        public int Value { get; set; }
    }
    

    and the following initialization:

    var groups = new [] { new Group(4, 1), new Group(5, 1),
                          new Group(6, 2), new Group(7, 3) };
    
    var fields = new [] { new GroupField(10, 4, 100),
                          new GroupField(11, 4, 300), 
                          new GroupField(12, 5, 200),  
                          new GroupField(13, 6, 100),  
                          new GroupField(14, 6, 200),  
                          new GroupField(15, 7, 100),  
                          new GroupField(16, 7, 300)
                        };
    
    var values = new [] { 100, 200 };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is probably a simple answer to this that someone can help me with
can someone help me with this problem? I've used file_get_contents() to get all text
I am being an idiot, probably, but can someone help. I want to change
Probably a very trivial problem. I have an object that looks like this: @PersistenceCapable
This is a problem I regularly bump into - hopefully someone can clarify to
OK probably a newbie mistake but I hope someone can help me. Let me
I have a quick and hopefully simple question that I hope someone can help
Hopping someone can help with this. When someone clicks 'Like' on one of our
This is, probably, a very simple answer for someone. I have a method with
I really can't get this working so i'm hoping someone here can help :)

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.