title: LINQ select distinct c#
body: <p>I'm trying to do a query that does not include repeated <code>IdUser</code> values, ​​but does not work.</p>
  
  <p><strong>this is my linq query:</strong></p>
  
  <pre><code>var sql= (from u in db.USER
            join c in db.CONSULT on u.IdUser equals c.IdUser 
            select new UsuersViewModel 
                   {  
                      IdUser = c.IdUser, 
                      DateCreate=c.DateCreate, 
                      IdTypeConsult = c.IdTypeConsult, 
                      Sex=u.Sex 
                   })
                   .Distinct();
  </code></pre>
  
  <p><strong>I want this:</strong></p>
  
  <pre><code>SELECT   distinct CONSULT.IdUser , CONSULT.DateCreate, 
           CONSULT.IdTypeConsult , USER.Sex
  FROM   CONSULT INNER JOIN
         USER ON CONSULT.IdUser = USER.IdUser 
  </code></pre>
  
  <p><strong>The query give duplicated records</strong></p>
  
  <p>Why doesn't it work?</p>