Exemplo n.º 1
0
        /// <summary>
        /// Builds the criterion.
        /// </summary>
        /// <param name="fieldName">Name of the field.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        protected override ICriterion BuildCriterion(string fieldName)
        {
            ICriterion result = null;

            switch (Operand)
            {
                case ArithmeticOperandEnum.Equal:
                    result = Restrictions.Eq(fieldName, Value);
                    break;

                case ArithmeticOperandEnum.NotEqual:
                    result = Restrictions.Not(Restrictions.Eq(fieldName, Value));
                    break;

                case ArithmeticOperandEnum.Greater:
                    result = new SimpleExpression(fieldName, Value, " > ");
                    break;

                case ArithmeticOperandEnum.Lower:
                    result = new SimpleExpression(fieldName, Value, " < ");
                    break;

                case ArithmeticOperandEnum.GreaterOrEqual:
                    result = Restrictions.Ge(fieldName, Value);
                    break;

                case ArithmeticOperandEnum.LowerOrEqual:
                    result = Restrictions.Le(fieldName, Value);
                    break;

                default:
                    throw new NotImplementedException();
            }

            if (Negation)
            {
                result = Restrictions.Not(result);
            }

            return result;
        }
Exemplo n.º 2
0
 /// <summary>
 /// </summary>
 /// <param name="propertyName"></param>
 /// <param name="flags"></param>
 /// <returns></returns>
 public static BitwiseFlags IsSet(string propertyName, int flags)
 {
     var lhs = new SimpleExpression(propertyName, flags, " & ");
     AbstractCriterion rhs = Expression.Sql("?", flags, NHibernateUtil.Int32);
     return new BitwiseFlags(lhs, rhs);
 }