title: C# Entity Framework / SQL Server count number of matched data
body: <p>Given a table Foo:</p>
  
  <pre><code>table Foo (
    name,
    city,
    country,
    year,
    color,
    age
  );
  </code></pre>
  
  <p>Data that is stored in the Foo table:</p>
  
  <pre><code>Peter, Brussels, Belgium, 2013, blue, 19
  Dirk, Brussels, Belgium, 1999, red, 33
  Jean, Paris, France, 2011, blue, 27
  </code></pre>
  
  <p>Line of data I want to match against database:</p>
  
  <pre><code>Peter, Brussels, Belgium, 2013, blue, 19 
  </code></pre>
  
  <p>==> should give for:</p>
  
  <pre><code>row 1: 100% or 6
  row 2: 33% or 2
  row 3: 16% or 1
  </code></pre>
  
  <p>Another line of data to test:</p>
  
  <pre><code>Peter, Paris, France, 2011, green, 36   
  </code></pre>
  
  <p>==> should give for:</p>
  
  <pre><code>row 1: 16% or 1
  row 2: 0% or 0
  row 3: 50% or 3
  </code></pre>
  
  <p>I could fetch all data in memory and run some C# logic on it, but that would not be the smartest thing.</p>
  
  <p>Would it be possible to do this kind of calculation ("% that matches row data") in a single query?</p>
  
  <p><strong>Bonus:</strong></p>
  
  <p>Is it possible to add weights to columns so that column 3 and 5 would add a higher count-weight?</p>
  
  <p>Using C# with EF with a code-first approach, and a SQL Server database (stored procedure is not an option as the database could be a different type).</p>