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
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.