示例#1
0
		/// <summary>
		///  This is used from ExpressionStdDev for evaluating avg.
		/// </summary>
		public ExpressionAvg (ExpressionElement E)
		{
			Elements.Add (E);
		}
示例#2
0
			public ExpressionElementComparer(ExpressionElement E1, DataRow Row)
			{
				_value1 = E1.Result (Row);

				_row = Row;

				if (_value1 == null || _value1 == DBNull.Value)
					return;

				_t1 = _value1.GetType ();
				_RT1 = E1.ResultType (Row);
			}
示例#3
0
			public int CompareTo (ExpressionElement E2)
			{
				object value1 = _value1;
				object value2 = E2.Result (_row);

				if ((value1 == null || value1 == DBNull.Value) && (value2 == null || value2 == DBNull.Value))
					return 0;
				else if (value2 == null || value2 == DBNull.Value)
					return 1;
				else if (value1 == null || value1 == DBNull.Value)
					return -1;

				Type t2 = value2.GetType ();
			
				Type RT2 = E2.ResultType (_row);

				if (_t1 == typeof (string) || t2 == typeof (string)) 
				{
					// FIXME: If one of elements are string they both should be???
					return String.Compare(value1.ToString(), value2.ToString(), !_row.Table.CaseSensitive);
				}

				if (_t1 != t2) 
				{
					value2 = Convert.ChangeType (value2, Type.GetTypeCode (_t1));
				}

				if (value1 is IComparable)
					return ((IComparable)value1).CompareTo(value2);

				return (int) _t1.InvokeMember ("CompareTo", BindingFlags.Default | 
					BindingFlags.InvokeMethod, null, 
					value1, 
					new object [] {value2});
			}
示例#4
0
		/// <summary>
		///  static method for comparing two ExpressionElement. This is used in =, <, >, <>, <=, >= elements.
		///  If elements are equal returns 0, if E1 is less that E2, return -1 else if E1 is greater 1 
		/// </summary>
		protected static int Compare (ExpressionElement E1, ExpressionElement E2, DataRow Row)
		{ 
			ExpressionElementComparer comparer = new ExpressionElementComparer(E1, Row);

			return comparer.CompareTo(E2);
		}