title: Linq Query to Get Distinct Records from Two Tables
body: <p>I have two Tables - tblExpenses and tblCategories as follows</p>
  
  <h1>tblExpenses</h1>
  
  <pre><code>ID (PK),
  Place,
  DateSpent,
  CategoryID (FK)
  </code></pre>
  
  <h1>tblCategory</h1>
  
  <pre><code>ID (PK),
  Name
  </code></pre>
  
  <p>I tried various LINQ approaches to get all distinct records from the above two tables but not with much success. I tried using UNION and DISTINCT but it didnt work.</p>
  
  <p>The above two tables are defined in my Model section of my project which in turn will create tables in SQLite. I need to retrieve all the distinct records from both the tables to display values in gridview.</p>
  
  <p>Kindly provide me some inputs to accomplish this task. I did some research to find answer to this question but nothing seemed close to what I wanted. Excuse me if I duplicated this question.</p>
  
  <p>Here is the UNION, DISTINCT approaches I tried:</p>
  
  <h1>DISTINCT #  ==> Gives me Repetitive values</h1>
  
  <pre><code>(from exp in db.Table&lt;tblExpenses &gt;()
                                     from cat in db.Table&lt;tblCategory&gt;()                                       
                                     select new { exp.Id, exp.CategoryId, exp.DateSpent, exp.Expense, exp.Place, cat.Name }).Distinct();
  </code></pre>
  
  <h1>UNION #  ==> Got an error while using UNION</h1>