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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:17:16+00:00 2026-05-11T20:17:16+00:00

I have a model where a Product can have multiple PriceDrops. I’m trying to

  • 0

I have a model where a Product can have multiple PriceDrops. I’m trying to generate a list of products with the most recent price drops.

Getting the most recent price drops with the products loaded is easy enough, and I thought it would be the best way to start:

dlo.LoadWith<PriceDrop>(pd => pd.Product);
db.LoadOptions = dlo;
return db.PriceDrops.OrderBy(d=>d.CreatedTime);

Works great for a list of recent price drops, but I want a list of products. If I append a “.Select(d=>d.Product)” I get a list of Products back – which is perfect – but they are no longer associated with the PriceDrops. That is, if I call .HasLoadedOrAssignedValues on the products, it returns false. If I try to interrogate the Price Drops, it tries to go back to the DB for them.

Is there a way around this, or do I have to craft a query starting with Products and not use the Select modifier? I was trying to avoid that, because in some cases I want a list of PriceDrops, and I wanted to re-use as much logic as possible (I left out the where clause and other filter code from the sample above, for clarity).

Thanks,
Tom

  • 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-11T20:17:16+00:00Added an answer on May 11, 2026 at 8:17 pm

    Try loading the Products, ordered by their latest PriceDrop:

    dlo.LoadWith<Product>(p => p.PriceDrops);
    db.LoadOptions = dlo;
    return db.Products.OrderBy(d => d.PriceDrops.Max(pd => pd.CreatedTime));
    

    I understand from your question that you’re trying to avoid this, why?

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

Sidebar

Related Questions

I have a Store Model that can have multiple products. Each product has a
I have 3 models. These are the User , Product and Price model. I
I have two models: Price :belongs_to Products Product :has_many Prices I created new Prices
Weird one. I have a model Product.rb, I have 10k products. I have title,
I have a model where an article can have multiple tags (and a tag
I have a model Product with a 1:n relationship with model Product_Tag. I also
I have Product model and it has many categories with a has_many :through association
Let's say that I have a Company model and a Product model, both of
I'm using Doctrine ODM with MongoDB. I have a product model like this: namespace
I have notes attribute in Product model with text something, something else. In views

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.