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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:02:34+00:00 2026-06-09T07:02:34+00:00

I am trying to filter displayed documents in a winforms app using a checked

  • 0

I am trying to filter displayed documents in a winforms app using a checked list box, so that when 2 tags are selected only documents containing those tags would show up and be further winnowed down when a third tag was selected. I am using Entity Framework. Here is what I have but I think it might not be efficient. I don’t like that I have to query the db so often. Any thoughts?

List<int> docIds = null;
        if (tags != null)
        {
            docIds.AddRange(from di in frmFocus._context.AllocateDocumentTags
                            where di.tagId == tags[0]
                            select di.documentId);
            for (int i = 1; i < tags.Length; i++)
            {
                List<int> docList = (from dId in frmFocus._context.AllocateDocumentTags
                                     where dId.tagId == tags[i]
                                     select dId.documentId).ToList();
                foreach (int n in docIds)
                {
                    if (!docList.Contains(n))
                    {
                        docIds.Remove(n);
                    }
                }
            }

        }

Now I am trying to display the docs based on the ids but… here’s the new code

docIds = (from di in frmFocus._context.AllocateDocumentTags.Distinct()
                                    where tags.Contains(di.tagId)
                                    select di.documentId).ToList();
                tagManagment.fillUsed(docIds);
            }
            ObjectSet<Documents> _docs = (from d in frmFocus._context.Documents
                     where docIds.Contains(d.id)
                     select d);
  • 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-09T07:02:36+00:00Added an answer on June 9, 2026 at 7:02 am

    You can basically just do a contains on tags:

    List<int> docIds = (from di in frmFocus._context.AllocateDocumentTags
                        where tags.Contains(di.tagId)
                        select di.documentId);
    

    For the JOIN:

    ObjectSet<Documents> _docs = (from doc in docIds
                                  join d in frmFocus._context.Documents.ToList()  on doc equals d.id
                                  select d);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to filter by a list of values using the criteria API. I
Im trying to filter rows based on a column say c1 that contains boolean
I am trying to filter a fusion table using the WHERE clause in order
I'm trying to filter some XML in JavaScript using E4X and have some specific
I am trying to filter for an object that has a Title field, and
I am trying to fade a box in by using an image with a
I am trying to get my TagsController#index action to display only the Questions that
I was trying to add thumbnail to list view but the problem is that
I'm trying to build a FileMaker Pro 11 layout that excludes records containing a
i'm trying to filter the $routeParams of the data returned from the json file.

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.