title: How to get a distinct result with nHibernate and QueryOver API?
body: <p>I have this Repository method</p>
  
  <pre><code>    public IList&lt;Message&gt; ListMessagesBy(string text, IList&lt;Tag&gt; tags, int pageIndex, out int count, out int pageSize)
      {
          pageSize = 10;
          var likeString = string.Format("%{0}%", text);
          var query = session.QueryOver&lt;Message&gt;()
              .Where(Restrictions.On&lt;Message&gt;(m =&gt; m.Text).IsLike(likeString) || 
              Restrictions.On&lt;Message&gt;(m =&gt; m.Fullname).IsLike(likeString));
  
          if (tags.Count &gt; 0)
          {
              var tagIds = tags.Select(t =&gt; t.Id).ToList();
              query
                  .JoinQueryOver&lt;Tag&gt;(m =&gt; m.Tags)
                  .WhereRestrictionOn(t =&gt; t.Id).IsInG(tagIds);
          }            
  
          count = 0;
          if(pageIndex &lt; 0)
          {
              count = query.ToRowCountQuery().FutureValue&lt;int&gt;().Value;
              pageIndex = 0;
          }
          return query.OrderBy(m =&gt; m.Created).Desc.Skip(pageIndex * pageSize).Take(pageSize).List();
      }
  </code></pre>
  
  <p>You supply a free text search string and a list of Tags.
  The problem is that if a message has more then one tag it is listed duplicated times. 
  I want a distinct result based on the Message entity. I've looked at</p>
  
  <pre><code>Projections.Distinct
  </code></pre>
  
  <p>But it requires a list of Properties to to the distinct question on. This Message is my entity root there most be a way of getting this behaviour without supplying all of the entity properties?</p>
  
  <p>Thanks in advance, Anders</p>