title: NHibernate QueryOver SQLFunction in where clause
body: <p>I would like to query a table having multiple rows, each with a <code>timestamp</code> with data coming at ten minute intervals. I would like to find the beginning of any missing data, which is where there is not a <code>timestamp</code> equaling the next ten minute interval, like this:</p>
  
  <pre><code>select a.[timestamp]
  from [table] as a
  where not exists (select 1
                    from [table] as b
                    where a.[id] = b.[id] 
  
                      and b.[timestamp] = dateadd(mi, 10, a.[timestamp]))
  
  order by a.[timestamp]
  </code></pre>
  
  <p>I have this so far, but I fail to see how to build the query to let me do the <strong>b.[timestamp] = dateadd(mi, 10, a.[timestamp])</strong> in the query above:</p>
  
  <pre><code>Table tableAlias = null;
  
  IList&lt;DateTimeOffset&gt; dateTimeOffsets = session.QueryOver(() =&gt; tableAlias)
  .WithSubquery
  .WhereNotExists(QueryOver.Of&lt;Table&gt;()
  .Where(x =&gt; x.Id == tableAlias.Id)
  
  .And(Restrictions.Eq(Projections.SqlFunction("addminutes",
                                               NHibernateUtil.DateTimeOffset,
                                               new[]
                                               {
                                                 Projections.Property("Timestamp"),
                                                 Projections.Constant(10)
                                               }),
                                               &lt;insert timestamp property again here&gt;))
  
  .Select(Projections.Constant(1)))
  .Select(x =&gt; x.Timestamp)
  .List&lt;DateTimeOffset&gt;();
  </code></pre>
  
  <p>I can not get my head round the restriction on the sqlfuntion part - <code>Nhibernate</code> just won't let me do the comparison of the sqlfunction and my timestamp.</p>
  
  <p>I hope I am on the right track with the code above, but please correct me if I'm totally off with my attempt at solving this...</p>
  
  <p>Kind regards</p>