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

The Archive Base Latest Questions

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

I am trying to find a way to pass in an optional string list

  • 0

I am trying to find a way to pass in an optional string list to a query. What I am trying to do is filter a list of tags by the relationship between them. For example if c# was selected my program would suggest only tags that appear in documents with a c# tag and then on the selection of the next, say SQL, the tags that are linked to docs for those two tags together would be shown, whittling it down so that the user can get closer and closer to his goal.

At the moment all I have is:

List<Tag> _tags =  (from t in Tags
                   where t.allocateTagDoc.Count > 0
                   select t).ToList();

This is in a method that would be called repeatedly with the optional args as tags were selected.


I think I have been coming at it arse-backwards. If I make two(or more) queries one for each supplied tag, find the docs where they all appear together and then bring out all the tags that go with them… Or would that be too many hits on the db? Can I do it entirely through an entity context variable and just query the model?

Thanks again for any help!

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

    Thought I would pop back and share my solution which was completely different to what I first had in mind.

    First I altered the database a little getting rid of a useless field in the allocateDocumentTag table which enabled me to use the entity framework model much more efficiently by allowing me to leave that table out and access it purely through the relationship between Tag and Document.

    When I fill my form the first time I just display all the tags that have a relationship with a document. Using my search filter after that, when a Tag is selected in a checkedListBox the Document id’s that are associated with that Tag(s) are returned and are then fed back to fill the used tag listbox.

    public static List<Tag> fillUsed(List<int> docIds = null)
            {
                List<Tag> used = new List<Tag>();
    
                if (docIds == null || docIds.Count() < 1)
                {
                    used = (from t in frmFocus._context.Tags
                            where t.Documents.Count >= 1
                            select t).ToList();  
                }
                else
                {    
                    used = (from t in frmFocus._context.Tags
                            where t.Documents.Any(d => docIds.Contains(d.id))
                            select t).ToList();  
                }
                return used;
            }
    

    From there the tags feed into the doc search and vice versa. Hope this can help someone else, if the answer is unclear or you need more code then just leave a comment and I’ll try and sort it.

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

Sidebar

Related Questions

I am trying to find a way to reverse a string, I've seen alternatives
I've been trying to find a proper way to pass some information, such as
I am trying to find the best way to pass complex configurations in a
I'm trying to find a good way to maintain PHP configuration differences between a
I'm trying to find an easy way to pass parameters from my C# class
I'm trying to find a way to implement a Linq-to-Entities compiled query of the
I'm trying to find a way to pass objects to the Azure Queue. I
I am trying to find a way to pass derived-type objects with allocatable components
I've been trying to find a way to pass a message to my Wallpaper
I'm trying to find a way to pass fout or cout to a function.

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.