예제 #1
0
 /// <summary>
 /// returns a EFQuery that is true if the innerCriteria evaluates true
 /// on the fieldName. (Assumes fieldName is a one-to-many navigational property).
 /// </summary>
 /// <returns>EFQuery</returns>
 public static EFQuery any(string fieldName, EFQuery innerCriteria)
 {
     return(new EFQuery
     {
         selectionComparison = SelectionComparison.Any,
         fieldName = fieldName,
         innerCriteria = innerCriteria
     });
 }
예제 #2
0
 public static EFQuery compare(SelectionComparison comparison, string fieldName, object rightHandSide)
 {
     return(new EFQuery
     {
         selectionComparison = comparison,
         fieldName = fieldName,
         rightHandSide = rightHandSide as EFQuery ?? EFQuery.constant(rightHandSide)
     });
 }
예제 #3
0
 public static EFQuery add(object left, object right)
 {
     return(new EFQuery
     {
         selectionComparison = SelectionComparison.Add,
         aggregateList = new[]
         {
             EFQuery.constant(left),
             EFQuery.constant(right)
         }
     });
 }
예제 #4
0
        private object executeAddExpression <T>(EFQuery sc, object context)
        {
            object result = null;

            foreach (var arg in sc.aggregateList)
            {
                if (!arg.isConstant)
                {
                    throw new ArgumentException(String.Format("{0} must be constant", sc));
                }

                if (result == null)
                {
                    result = getConstantValue(arg.constantValue, context);
                    continue;
                }

                var value = getConstantValue(arg.constantValue, context);

                // Until we figure out how to make Json.NET deserialize into TimeSpan objects ...
                var s = value as string;
                if (s != null)
                {
                    TimeSpan span;
                    if (TimeSpan.TryParse(s, out span))
                    {
                        value = span;
                    }
                }

                var leftType  = result.GetType();
                var rightType = value.GetType();

                var methodInfo = leftType.GetMethod("Add", new[] { rightType });

                if (methodInfo == null)
                {
                    throw new ArgumentException(
                              String.Format("Cannot find operation \"Add\" for type \"{0}\"", leftType));
                }

                result = methodInfo.Invoke(result, new[] { value });
            }

            return(result);
        }
예제 #5
0
 /// <summary>
 /// returns a EFQuery that is true if all of the EFQuery evaluates false
 /// </summary>
 /// <returns>EFQuery</returns>
 public static EFQuery not(EFQuery efQuery)
 {
     return(nand(new[] { efQuery }));
 }