public static SqlByte Subtract(SqlByte x, SqlByte y) { return (x - y); }
public static SqlByte Xor(SqlByte x, SqlByte y) { return (x ^ y); }
public static SqlBoolean NotEquals(SqlByte x, SqlByte y) { return (x != y); }
public static SqlByte OnesComplement(SqlByte x) { return ~x; }
public static SqlBoolean op_Explicit(SqlByte x) { if (x.IsNull) return SqlBoolean.Null; return new SqlBoolean(x.Value != 0); }
public static SqlByte Multiply(SqlByte x, SqlByte y) { return (x*y); }
public static SqlBoolean LessThan(SqlByte x, SqlByte y) { return (x < y); }
public static SqlByte BitwiseOr(SqlByte x, SqlByte y) { return (x | y); }
public static SqlBoolean GreaterThan(SqlByte x, SqlByte y) { return (x > y); }
public static SqlBoolean GreaterThanOrEqual(SqlByte x, SqlByte y) { return (x >= y); }
public static SqlBoolean Equals(SqlByte x, SqlByte y) { return (x == y); }
public static SqlByte Divide(SqlByte x, SqlByte y) { return (x/y); }
public int CompareTo(SqlByte value) { if (value.IsNull) { return 1; } else { return this.value.CompareTo(value.Value); } }
public static SqlByte Add(SqlByte x, SqlByte y) { return (x + y); }
public static SqlBoolean LessThanOrEqual(SqlByte x, SqlByte y) { return (x <= y); }
public static SqlByte BitwiseAnd(SqlByte x, SqlByte y) { return (x & y); }
// Why did Microsoft add this method in 2.0??? What's // the difference???? public static SqlByte Modulus(SqlByte x, SqlByte y) { return (x%y); }
public void SqlTypes_SqlByte() { NpgsqlParameter parameter; SqlByte value = new SqlByte(0x0d); #if NET_2_0 parameter = new NpgsqlParameter (); parameter.NpgsqlValue = value; Assert.AreEqual (NpgsqlDbType.TinyInt, parameter.NpgsqlDbType, "#A:NpgsqlDbType"); Assert.AreEqual (value, parameter.NpgsqlValue, "#A:NpgsqlValue"); Assert.AreEqual (value, parameter.Value, "#A:Value"); parameter = new NpgsqlParameter (); parameter.NpgsqlValue = SqlByte.Null; Assert.AreEqual (NpgsqlDbType.TinyInt, parameter.NpgsqlDbType, "#B:NpgsqlDbType"); Assert.AreEqual (SqlByte.Null, parameter.NpgsqlValue, "#B:NpgsqlValue"); Assert.AreEqual (SqlByte.Null, parameter.Value, "#B:Value"); #endif parameter = new NpgsqlParameter(); parameter.Value = value; Assert.AreEqual(NpgsqlDbType.TinyInt, parameter.NpgsqlDbType, "#C:NpgsqlDbType"); #if NET_2_0 Assert.AreEqual (value, parameter.NpgsqlValue, "#C:NpgsqlValue"); #endif Assert.AreEqual(value, parameter.Value, "#C:Value"); }
// devnote: This method should not be used with SqlDbType.Date and SqlDbType.DateTime2. // With these types the values should be used directly as CLR types instead of being converted to a SqlValue internal static object GetSqlValueFromComVariant(object comVal) { object sqlVal = null; if ((null != comVal) && (DBNull.Value != comVal)) { if (comVal is float) { sqlVal = new SqlSingle((float)comVal); } else if (comVal is string) { sqlVal = new SqlString((string)comVal); } else if (comVal is double) { sqlVal = new SqlDouble((double)comVal); } else if (comVal is System.Byte[]) { sqlVal = new SqlBinary((byte[])comVal); } else if (comVal is System.Char) { sqlVal = new SqlString(((char)comVal).ToString()); } else if (comVal is System.Char[]) { sqlVal = new SqlChars((System.Char[])comVal); } else if (comVal is System.Guid) { sqlVal = new SqlGuid((Guid)comVal); } else if (comVal is bool) { sqlVal = new SqlBoolean((bool)comVal); } else if (comVal is byte) { sqlVal = new SqlByte((byte)comVal); } else if (comVal is Int16) { sqlVal = new SqlInt16((Int16)comVal); } else if (comVal is Int32) { sqlVal = new SqlInt32((Int32)comVal); } else if (comVal is Int64) { sqlVal = new SqlInt64((Int64)comVal); } else if (comVal is Decimal) { sqlVal = new SqlDecimal((Decimal)comVal); } else if (comVal is DateTime) { // devnote: Do not use with SqlDbType.Date and SqlDbType.DateTime2. See comment at top of method. sqlVal = new SqlDateTime((DateTime)comVal); } else if (comVal is XmlReader) { sqlVal = new SqlXml((XmlReader)comVal); } else if (comVal is TimeSpan || comVal is DateTimeOffset) { sqlVal = comVal; } #if DEBUG else { Debug.Assert(false, "unknown SqlType class stored in sqlVal"); } #endif } return(sqlVal); }