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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:39:06+00:00 2026-05-30T13:39:06+00:00

I’m a beginner in using Linq and a lot of it is completely confusing

  • 0

I’m a beginner in using Linq and a lot of it is completely confusing right now.

I downloaded and used the LinqFlickr library from http://linqflickr.codeplex.com. I think however that this is just my lack of understanding about Linq. There isn’t much documentation on the LinqFlickr project for me to go on.

If I run the following code, if the username string is blank, it runs fine and returns photos with a specific tag. But if there is a username in it, it should refine the previous results by specific users, instead it gives me a bunch of random photos.

            var photos = (from ph in context.Photos
                      where
                      ph.SearchMode == SearchMode.TagsOnly
                      && ph.SearchText == tag
                      && ph.PhotoSize == PhotoSize.Small
                      && ph.Extras == (ExtrasOption.Owner_Name |  ExtrasOption.Date_Taken)
                      select ph);

            if (username != "")
            {
                string personId = (from people in context.Peoples
                                where 
                                people.Username == username
                                select people.Id).First();
                photos = photos.Where(q => q.NsId == personId) ;
            }

            photos = photos.Take(10);

I tried using some debugging tools such as LinqPad and MetaLinq but I haven’t been able to solve it with them.

Also, I’m sure my Linq query could be made in one query which would be great, but please explain it so a Linq newbie can understand!

  • 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-30T13:39:07+00:00Added an answer on May 30, 2026 at 1:39 pm

    Your query looks fine. My guess would be that this is a bug (or unintuitive by-design behaviour) in Athena where an extra “chained” where clause causes the original where clause to be forgotten.

    Assemble the second query independently (i.e. all the constraints in one big where clause) and check that this fixes things. If it does, it’s definitely a bug in the API. You can work around this by using LINQKit to assemble and expand the predicate for the where clause dynamically. Here’s how this might look:

    // Original predicate without userId constraint
    Expression<Func<Photo, bool>> predicate = ph =>  
            ph.SearchMode == SearchMode.TagsOnly
         && ph.SearchText == tag
         && ph.PhotoSize == PhotoSize.Small
         && ph.Extras == (ExtrasOption.Owner_Name |  ExtrasOption.Date_Taken);
    
    if (!string.IsNullOrEmpty(username)) 
    {
        // Build the userId constraint into the predicate.
    
        var personId = (from people in context.Peoples
                        where  people.Username == username
                        select people.Id).First();
    
        // "And" combines the predicates
        // "Expand" removes the use of invocation expressions, which 
        // some LINQ providers have problems with.
        predicate = predicate.And(q => q.NsId == personId).Expand();
    }
    
    // Final result
    var photos = context.Photos.Where(predicate).Take(10);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.