SYSTEM.DATA.SQLTYPES Most of the SqlTypes implement many of

SYSTEM.DATA.SQLTYPES Most of the SqlTypes implement many of the specially named operators. Most of the operators are also implemented by CLR numeric types. The numeric operations that are implemented by a SqlType are just as performant as the ones on its corresponding CLR type in most cases, so typically there is no performance to be gained by coercing a SqlType to its corresponding CLR type to do a calculation. The one exception to this is SqlDecimal. The numeric operations that are part of SqlDecimal may not be as fast as those on the CLR decimal type, but they cover a much wider range of numbers. SqlDecimalcan represent any number that the SQL Server decimal can, which is not the case for the CLR decimal type. For example, the largest number that SqlDecimal can represent is 99999999999999999999999999999999999999, but the largest number that the CLR decimal type can represent is only 79228162514264337593543950335. This property of SqlDecimalmay cause a runtime error if it is coerced to the CLR decimaltype and the value of the SqlDecimalis out of the range of values that the CLR decimalcan represent. SqlDecimal sd = SqlDecimal.MaxValue; // this causes a conversion and produces a runtime error decimal d = sd.Value; The semantics of the operation invoked depends on the type. For arithmetic types like SqlInt32, the operands are added by the op_Addition method. For the SqlBinary type, the operands are concatenated. In general, the semantics will be intuitive. For specific details, consult the MSDN documentation. Table 3-4 shows the operations that each SqlType can perform. The first column on the left lists the SqlType. The columns are marked with an X to indicate that the operation listed at the head of the column is available for the SqlType in the same row on the left. The operation includes the symbol used by C# and the name of the operation. Other languages may use different symbols for these operations. For example, this shows that SqlBinarysupports the = =, +, >, >=, !=, < , and <= operations. Note that for SqlBoolean, the Ones Complement operator means Logical Not. Every SqlType implements the IComparable interface. This interface has one method, CompareTo. Its signature follows. int CompareTo(object obj) This signature is a bit deceptive. Even though it implies any object can be passed in, in fact only objects that are of the same type as the SqlType Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP Web Hosting services

Bookmark the permalink.

Comments are closed.