[Mono-list] ExpressionElement.cs patch

Marco Canini marco.canini@fastwebnet.it
07 Oct 2003 01:49:01 +0200


--=-+i1HY/wuTXCt6H9K42fO
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

This patch solves a problem in ExpressionSingleElement class when using
integer number bigger than Int32.Max or floating point number.
I've also added the support for datetime.
I've tested it with my app and now i don't get an overflow exception.

-- 
Marco Canini <marco.canini@fastwebnet.it>

--=-+i1HY/wuTXCt6H9K42fO
Content-Disposition: attachment; filename=patchfile
Content-Type: text/x-patch; name=patchfile; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

Index: ExpressionElement.cs
===================================================================
RCS file: /mono/mcs/class/System.Data/System.Data/ExpressionElement.cs,v
retrieving revision 1.4
diff -u -r1.4 ExpressionElement.cs
--- ExpressionElement.cs	4 Sep 2003 15:51:07 -0000	1.4
+++ ExpressionElement.cs	6 Oct 2003 23:36:31 -0000
@@ -1646,13 +1646,17 @@
 				Element = s.Substring (1, s.Length - 2);
 				_ResultType = typeof (string);
 			}
+			if (s.StartsWith ("#") && s.EndsWith ("#")) {
+				Element = DateTime.Parse (s.Substring (1, s.Length - 2));
+				_ResultType = typeof (DateTime);
+			}
 			else if (!Char.IsDigit (s [0]) && s [0] != '-' && s [0] != '+') {
 				Element = s;
 				_ResultType = typeof (DataColumn);
 			}
 			else {
-				_ResultType = typeof (int);
-				Element = int.Parse (s);
+				Element = Decimal.Parse (s);
+				_ResultType = typeof (Decimal);
 			}				
         	}
 
@@ -1768,8 +1772,8 @@
 			Type RT1 = E1.ResultType (Row);
 			Type RT2 = E2.ResultType (Row);
 
-			// If one of elements are string they both should be??? FIXME 
 			if (t1 == typeof (string) || t2 == typeof (string)) {
+				// FIXME: If one of elements are string they both should be???				
 				
 				//TempType = typeof (string);				
 				if (t1 != typeof (string))
@@ -1782,13 +1786,7 @@
 					value1 = ((string)value1).ToLower ();
 					value2 = ((string)value2).ToLower ();
 				}
-			}
-			else if (t1 != t2) {
-				
-				value2 = Convert.ChangeType (value2, Type.GetTypeCode (t1));
-			}
-
-			else if (t1 != t2) {
+			} else if (t1 != t2) {
 
 				value2 = Convert.ChangeType (value2, Type.GetTypeCode (t1));
 			}

--=-+i1HY/wuTXCt6H9K42fO--