2 // System.Data.SqlTypes.SqlInt32
5 // Rodrigo Moya (rodrigo@ximian.com)
6 // Daniel Morgan (danmorg@sc.rr.com)
7 // Tim Coleman (tim@timcoleman.com)
9 // (C) Ximian, Inc. 2002
10 // (C) Copyright 2002 Tim Coleman
15 namespace System.Data.SqlTypes
19 /// a 32-bit signed integer to be used in reading or writing
20 /// of data from a database
22 public struct SqlInt32 : INullable, IComparable
28 public static readonly SqlInt32 MaxValue = new SqlInt32 (2147483647);
29 public static readonly SqlInt32 MinValue = new SqlInt32 (-2147483648);
30 public static readonly SqlInt32 Null;
31 public static readonly SqlInt32 Zero = new SqlInt32 (0);
37 public SqlInt32(int value)
47 get { return (bool) (this == Null); }
53 throw new SqlNullValueException ("The property contains Null.");
63 public static SqlInt32 Add (SqlInt32 x, SqlInt32 y)
68 public static SqlInt32 BitwiseAnd(SqlInt32 x, SqlInt32 y)
73 public static SqlInt32 BitwiseOr(SqlInt32 x, SqlInt32 y)
79 public int CompareTo(object value)
81 throw new NotImplementedException ();
84 public static SqlInt32 Divide(SqlInt32 x, SqlInt32 y)
90 public override bool Equals(object value)
92 throw new NotImplementedException ();
95 public static SqlBoolean Equals(SqlInt32 x, SqlInt32 y)
100 public override int GetHashCode()
105 public static SqlBoolean GreaterThan (SqlInt32 x, SqlInt32 y)
110 public static SqlBoolean GreaterThanOrEqual (SqlInt32 x, SqlInt32 y)
115 public static SqlBoolean LessThan(SqlInt32 x, SqlInt32 y)
120 public static SqlBoolean LessThanOrEqual(SqlInt32 x, SqlInt32 y)
125 public static SqlInt32 Mod(SqlInt32 x, SqlInt32 y)
130 public static SqlInt32 Multiply(SqlInt32 x, SqlInt32 y)
135 public static SqlBoolean NotEquals(SqlInt32 x, SqlInt32 y)
140 public static SqlInt32 OnesComplement(SqlInt32 x)
145 public static SqlInt32 Parse(string s)
147 throw new NotImplementedException ();
150 public static SqlInt32 Subtract(SqlInt32 x, SqlInt32 y)
155 public SqlBoolean ToSqlBoolean()
157 return ((SqlBoolean)this);
160 public SqlByte ToSqlByte()
162 return ((SqlByte)this);
165 public SqlDecimal ToSqlDecimal()
167 return ((SqlDecimal)this);
170 public SqlDouble ToSqlDouble()
172 return ((SqlDouble)this);
175 public SqlInt16 ToSqlInt16()
177 return ((SqlInt16)this);
180 public SqlInt64 ToSqlInt64()
182 return ((SqlInt64)this);
185 public SqlMoney ToSqlMoney()
187 return ((SqlMoney)this);
190 public SqlSingle ToSqlSingle()
192 return ((SqlSingle)this);
196 public SqlString ToSqlString ()
198 throw new NotImplementedException ();
202 public override string ToString()
204 throw new NotImplementedException ();
207 public static SqlInt32 Xor(SqlInt32 x, SqlInt32 y)
217 public static SqlInt32 operator + (SqlInt32 x, SqlInt32 y)
219 return new SqlInt32 (x.Value + y.Value);
223 public static SqlInt32 operator & (SqlInt32 x, SqlInt32 y)
225 return new SqlInt32 (x.Value & y.Value);
229 public static SqlInt32 operator | (SqlInt32 x, SqlInt32 y)
231 return new SqlInt32 (x.Value | y.Value);
235 public static SqlInt32 operator / (SqlInt32 x, SqlInt32 y)
237 return new SqlInt32 (x.Value / y.Value);
241 public static SqlBoolean operator == (SqlInt32 x, SqlInt32 y)
243 if (x.IsNull || y.IsNull)
244 return SqlBoolean.Null;
246 return new SqlBoolean (x.Value == y.Value);
249 // Bitwise Exclusive-OR (XOR)
250 public static SqlInt32 operator ^ (SqlInt32 x, SqlInt32 y)
252 return new SqlInt32 (x.Value ^ y.Value);
256 public static SqlBoolean operator >(SqlInt32 x, SqlInt32 y)
258 if (x.IsNull || y.IsNull)
259 return SqlBoolean.Null;
261 return new SqlBoolean (x.Value > y.Value);
265 public static SqlBoolean operator >= (SqlInt32 x, SqlInt32 y)
267 if (x.IsNull || y.IsNull)
268 return SqlBoolean.Null;
270 return new SqlBoolean (x.Value >= y.Value);
273 // != Inequality Compare
274 public static SqlBoolean operator != (SqlInt32 x, SqlInt32 y)
276 if (x.IsNull || y.IsNull)
277 return SqlBoolean.Null;
279 return new SqlBoolean (x.Value != y.Value);
283 public static SqlBoolean operator < (SqlInt32 x, SqlInt32 y)
285 if (x.IsNull || y.IsNull)
286 return SqlBoolean.Null;
288 return new SqlBoolean (x.Value < y.Value);
292 public static SqlBoolean operator <= (SqlInt32 x, SqlInt32 y)
294 if (x.IsNull || y.IsNull)
295 return SqlBoolean.Null;
297 return new SqlBoolean (x.Value <= y.Value);
301 public static SqlInt32 operator % (SqlInt32 x, SqlInt32 y)
303 return new SqlInt32 (x.Value % y.Value);
306 // Compute Multiplication
307 public static SqlInt32 operator * (SqlInt32 x, SqlInt32 y)
309 return new SqlInt32 (x.Value * y.Value);
313 public static SqlInt32 operator ~ (SqlInt32 x)
315 return new SqlInt32 (~x.Value);
319 public static SqlInt32 operator - (SqlInt32 x, SqlInt32 y)
321 return new SqlInt32 (x.Value - y.Value);
325 public static SqlInt32 operator - (SqlInt32 x)
327 return new SqlInt32 (-x.Value);
331 public static explicit operator SqlInt32 (SqlBoolean x)
336 return new SqlInt32 ((int)x.ByteValue);
339 public static explicit operator SqlInt32 (SqlDecimal x)
344 return new SqlInt32 ((int)x.Value);
347 public static explicit operator SqlInt32 (SqlDouble x)
352 return new SqlInt32 ((int)x.Value);
355 public static explicit operator int (SqlInt32 x)
360 public static explicit operator SqlInt32 (SqlInt64 x)
365 return new SqlInt32 ((int)x.Value);
368 public static explicit operator SqlInt32(SqlMoney x)
373 return new SqlInt32 ((int)x.Value);
376 public static explicit operator SqlInt32(SqlSingle x)
381 return new SqlInt32 ((int)x.Value);
385 public static explicit operator SqlInt32(SqlString x)
387 throw new NotImplementedException ();
390 public static implicit operator SqlInt32(int x)
392 return new SqlInt32 (x);
395 public static implicit operator SqlInt32(SqlByte x)
400 return new SqlInt32 ((int)x.Value);
403 public static implicit operator SqlInt32(SqlInt16 x)
408 return new SqlInt32 ((int)x.Value);