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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:38:46+00:00 2026-05-18T00:38:46+00:00

Good Evening everyone, I’ve been trying to figure out the most efficient way to

  • 0

Good Evening everyone,

I’ve been trying to figure out the most efficient way to do this, but am falling short. Here’s how it goes…

I am ultimately trying to determine “like customers” based on a specific customer’s buying habits and a given threshold, say 50%. IE customer 1 purchased products A,B,C,D … customer 2 purchased B,C,D,E … these two customers are >= 50% “likeness” so they should be matched.

My schema is as would be expected

CLIENT (1 ----- many)  CLIENT_PURCHASE (1 -------many) PRODUCT

*clientID            *clientID *prodID                 *prodID

For now I am ignoring the threshold and simply am trying to find customers who have purchased any item within customer 1’s history. I think I have this working with the following two queries:

var clientOneHistory = (from cp in client.Client_Purchase
                        select cp.prodID).ToList();

var matchedClients = (from cp in db.Client_Purchase
                        where clientOneHistory.Contains(cp.prodID)
                        select cp.Client.fullname).Distinct().ToList();

So my ultimate question is, “How do I work in the threshold portion?”
Thanks for your time

  • 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-18T00:38:46+00:00Added an answer on May 18, 2026 at 12:38 am

    I’m not sure exactly how to form these queries for your particular case. Assuming you want to use LINQ-to-SQL. Instead, I’ll use the NorthWind database as an example to do the same thing. You could then use the ideas used here in your implementation. I don’t think it’s possible to do this completely using LINQ-to-SQL, you’ll have to do a mix.

    var threshold = 0.5M;
    
    // let's pick a customer id
    var myId = "VINET";
    
    // get products of current customer
    var myProducts = (from c in db.Customers
                      where c.CustomerID == myId
                      join o in db.Orders on c.CustomerID equals o.CustomerID
                      join od in db.Order_Details on o.OrderID equals od.OrderID
                      select od.ProductID)
                     .Distinct()
                     .ToArray();
    
    // get the products of all other customers
    var others = (from c in db.Customers
                  where c.CustomerID != myId
                  join o in db.Orders on c.CustomerID equals o.CustomerID
                  join od in db.Order_Details on o.OrderID equals od.OrderID
                  group od.ProductID by c.CustomerID into g
                  select new { CustomerID = g.Key, Products = g.Distinct() })
                 .AsEnumerable();
    
    // calculate "likeness" values for each person
    var likeness = from o in others
                   let Percent = Decimal.Divide(myProducts.Intersect(o.Products).Count(), myProducts.Length)
                   where Percent >= threshold
                   select new { o.CustomerID, Percent };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good evening everyone, I am currently trying to cleanup my inline JS and break
Good evening, This is my 1st time on this site, I have been programming
Good evening, people! I'm trying to solve a rather simple problem, but.. well, it
Good Evening, I'm using this script, it works really good but I want it
Good evening everyone, I was hoping you could help with an Objective-C question I
Good evening everyone. I am puzzling over the oddity that the jQuery Marquee plugin
Good evening guys. I'm currently trying to get started on development of a project
Good evening, I'm having an issue with Masonry. This is all my relevant code:
Good evening all, I've been working on an MD5 tool in C# that takes
Good evening, I am trying to generalize the histogram filter localization to discrete environments

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.