Search code examples
nhibernatenhibernate-criteria

DetachedCriteria equivalent needed


I need the DetachedCriteria equivalent to the following HQL:

select obj
from Objects obj, Text text
where obj.TextId = text.TextId and <Some_Other_Condition>
order by text.Value

Thanx


Solution

  • It's all depending of your Mapped objects

    Here is an example:

        var criteriaObject = DetachedCriteria.For(typeof(Objects))
            .CreateAlias("TextReference", "text")
            .Add(Restrictions.Eq("Activate", true))
            .AddOrder(new Order("text.Value", true));
    

    Hope it helps