Lawtonfogle
Lawtonfogle

Reputation: 959

How to add a true/false to a disjunction/conjunction in nhibernate?

I saw a few older posts mentioning MyDisjunction.Add(Restrictions.Sql("(1=1)")), but I couldn't find the Sql function (does it still exist?).

Instead, I am using MyDisjunction.Add(Restriction.Where<MyObject>(x => x.SomeProperty == x.SomeProperty)) (!= for false), but this feels like I'm abusing the use of Restriction.Where. Is there something more natural to use?

Upvotes: 0

Views: 536

Answers (1)

Radim K&#246;hler
Radim K&#246;hler

Reputation: 123861

Check the class Expression

var alwaysTrue = Expression.Sql("1 = 1");

...
   .Add(alwaysTrue)

But this is a code snippet from Expression class source:

namespace NHibernate.Criterion
{
    /// <summary>
    /// This class is semi-deprecated. Use <see cref="Restrictions"/>.
    /// </summary>
    /// <seealso cref="Restrictions"/>
    public sealed class Expression : Restrictions
    ...

Upvotes: 1

Related Questions