LINQ Gymnastics: Creating A Predictive Query With LINQ(blog.wekeroad.com)
submitted by
adminjew(1490) 4 years, 2 months ago
The Code
I wrote about this before, but the best way to approach a difficult query is to cut it up into pieces. It really helps in this case, since what we’re doing is statistical and therefore may seem simple, but isn’t really. So let’s break it out:
* We need to know all the Orders that our Product was part of
* We need all of the Products that were part of those Orders, omitting the one we just bought
* We need to roll these up by the SUM of the quantity of the products bought, and order them in descending order
* We need to take the top 5 of this SUM, and query the Products table for the related Products
|category: Linq
|Views: 5
tags:
LINQ another
Everyones tags:
Your Tags: