Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is the LINQ query involved that creates the object I am talking about, and the problem line is:</p> <p><strong>.Where (searchWord => queryTerms.Contains(searchWord.Word))</strong> </p> <pre><code>List&lt;queryTerm&gt; queryTerms = MakeQueryTermList(); public static List&lt;RelevanceTableEntry&gt; CreateRelevanceTable(List&lt;queryTerm&gt; queryTerms) { SearchDataContext myContext = new SearchDataContext(); var productRelevance = (from pwords in myContext.SearchWordOccuranceProducts where (myContext.SearchUniqueWords .Where (searchWord =&gt; queryTerms.Contains(searchWord.Word)) .Select (searchWord =&gt; searchWord.Id)).Contains(pwords.WordId) orderby pwords.WordId select new {pwords.WordId, pwords.Weight, pwords.Position, pwords.ProductId}); } </code></pre> <p>This query returns a list of WordId's that match the submitted search string (when it was List and it was just the word, that works fine, because as an answerer mentioned before, they were the same type of objects). My custom type <strong>here</strong> is queryTerms, a List that contains WordId, ProductId, Position, and Weight. From there I go about calculating the relevance by doing various operations on the created object. Sum "Weight" by product, use position matches to bump up Weights, etc. My point for keeping this separate was that the rules for doing those operations will change, but the basic factors involved will not. I would have even rather it be MORE separate (I'm still learning, I don't want to get fancy) but the rules for local and interpreted LINQ queries seems to trip me up when I do.</p> <p>Since CF has supported queries of queries forever, that's how I tend to lean. Pull the data you need from the db, then do your operations (which includes queries with Aggregate functions) on the in-memory table.</p> <p>I hope that makes it more clear. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload