Ejemplo n.º 1
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});
			}
Ejemplo n.º 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);
			}