Linq 2 NHibernate is for SQL Server database only.
Also it could be solved by HQL query but HQL is kind of script and this technic has problems like using dynamic SQL.
So i think the best solution is using crieteria object.
I made some progress this is my nhibernate criteria code
Code:
var criteria = session.CreateCriteria(typeof(Continuity),"r");
var subCriteria = DetachedCriteria.For<Continuity>("l");
subCriteria.SetProjection(Projections.Constant(1));
subCriteria.Add(Restrictions.EqProperty("r.Id", "l.Id"));
criteria.Add(Subqueries.NotExists(subCriteria));
This code creates the this SQL Query:
select l.id as start
from ContSeq as l
WHERE NOT EXISTS(SELECT 1 from ContSeq as r WHERE l.id = r.id)I need help to complate the criteria to produce this query
select l.id + 1 as start
from ContSeq as l
WHERE NOT EXISTS(SELECT 1 from ContSeq as r WHERE l.id + 1 = r.id)