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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:40:04+00:00 2026-05-16T14:40:04+00:00

Me again with a dumb question/scenario I need advice on. I have the following

  • 0

Me again with a dumb question/scenario I need advice on.

I have the following that pulls back the contents of a column:

return getappropriateuserfield.tblAutoComplete
                    .Where(p => p.MemberId == memberid && p.ACItem == acitem)
                    .Select(p => p.ACColumn)
                    .Distinct()
                    .ToArray();

Depending upon this result, I’d like to then take the ACColumn result, go to tblPreferences, look down ColumnName, and if it matches an entry in there, pull back the Alias (present in tblPreferences)

So, for example we have tblAutoComplete:

    MemberID ACItem ACColumn
        1      2     UUF1

tblPreferences looks like

    MemberID ColumnName Alias
       1       UUF1    Category

If the user sticks in “2” as the ACItem, the first part result would be “UUF1” – the linq above does this.

How do I alter the linq so that the second part takes place, ie. takes the UUF1, looks in tblPreferences, checks out ColumnName, sees the result matches so the final result is the Alias, “Category”

Do I need to do this in 2 parts or can I do it as one query, potentially using a join?

Apologies for the thickness.

  • 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-16T14:40:05+00:00Added an answer on May 16, 2026 at 2:40 pm

    Looks like a join to me, which is probably most easily expressed with a query expression:

    var query = from ac in foo.tblAutoComplete
                where ac.MemberId == memberid && ac.ACItem == acitem
                join pref in foo.tblPreferences.Where(x => x.MemberId == memberid)
                  on ac.ACColumn equals pref.ColumnName
                select pref.Category;
    

    Note that I’ve removed the Distinct() call here, which means you may get repeats. You can put Distinct() on the output, of course.

    The result of will be an IQueryable<string> (assuming Category is a string). If you need more bits, you could use an anonymous type.

    EDIT: I’ve edited the query so it’s got an extra “where” clause when fetching the preferences to start with. That should be equivalent to adding MemberId to the join.

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

Sidebar

Related Questions

Again I have a question regarding this plugin: http://t.wits.sg/2008/06/20/jquery-progress-bar-11/ What I want to achieve
The question is quite dumb, but I need to do it in a very
Every now and again I find myself doing something moderately dumb that results in
I am not sure whether I am asking a dumb question again or not
I have a really dumb question. Please forgive it's late and I am tired.
Just a simple question that might seems dumb but I'm not a git expert!
This is such a dumb question that I feel like I must be missing
I don't know if this is a dumb question or not but again as
Again, I was creating buttons dynamically based on this post and now I need
Again, I saw this sentence: A .classpath file snippet that can be included 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.