title: LINQ Return DISTINCT Values
body: <p>I have a LINQ to Entities query that I want to return only unique values of TagID and TagName.</p>
  
  <p>Code:</p>
  
  <pre><code>var tags = (from t in _dbContext.TaskRecordDetails.ToList()
                         join tag in _dbContext.Tags on t.TagName equals tag.TagName
                         where t.Period == period
                         select new TagDTO()
                         {
                             TagID = tag.TagID,
                             TagName = tag.TagName
                         });
  
              return tags.Distinct&lt;TagDTO&gt;();
  </code></pre>
  
  <p>However, duplicate rows are still returned as below. How do I ensure only unique rows are returned?</p>
  
  <pre><code>[
      {
          "TagID": 1,
          "TagName": "Level 1",
          "TagDescription": null,
          "IsActive": false
      },
      {
          "TagID": 2,
          "TagName": "Level 3",
          "TagDescription": null,
          "IsActive": false
      },
      {
          "TagID": 3,
          "TagName": "Level 5",
          "TagDescription": null,
          "IsActive": false
      },
      {
          "TagID": 1,
          "TagName": "Level 1",
          "TagDescription": null,
          "IsActive": false
      },
      {
          "TagID": 2,
          "TagName": "Level 3",
          "TagDescription": null,
          "IsActive": false
      }
  ]
  </code></pre>