예제 #1
0
        public static string BuildCondition(this QueryCondition condition, int token)
        {
            var operand = string.Empty;
            var value   = string.Empty;

            switch (condition.Term.Operathor)
            {
            case Operathor.Equals:
                operand = " == ";
                break;

            case Operathor.NotEquals:
                operand = " != ";
                break;

            case Operathor.GreaterThan:
                operand = " > ";
                break;

            case Operathor.GreaterThanEqualTo:
                operand = " >= ";
                break;

            case Operathor.LessThan:
                operand = " < ";
                break;

            case Operathor.LessThanEqualTo:
                operand = " <= ";
                break;

            case Operathor.Contains:
                value = string.Format("{0}.Contains(@{1})", condition.Property.Name, token);
                break;

            case Operathor.NotContains:
                value = string.Format("!{0}.Contains(@{1})", condition.Property.Name, token);
                break;

            default:
                operand = " == ";
                break;
            }

            return(string.IsNullOrEmpty(value) ? condition.MakeBinaryOperation(operand, token) : value);
        }