IMPLEMENTING LDIM get { return units; } //

IMPLEMENTING LDIM get { return units; } // set must validate set { // if null is passed in make it null if (value.IsNull) { SetNull(); return; } // if valid unit is passed in then change // unit and adjust value to match if (value == in || value == ft || value == yd ) { double curFactor = Factor(units); double newFactor = Factor(value.Value); units = value.Value; this.value *= curFactor / newFactor; return; } // if you get to here an // invalid unit was passed in so throw an exception throw new ApplicationException(value.Value + Is not valid unit , null); } } } This code has a Unit property that wraps the units field in LDim. The set portion of the property validates any change to the units field and throws an exception when an attempt is made to set units to an unsupported value. Note that this code is much more complex than just exposing a field. However, any code you add to SQL Server 2005 must protect the integrity of the database no matter what. The get part of the property is straightforward; it just returns the current value of units. The set part of the property must do two things. One is to check that a valid unit string is being used. The other is to convert the current value of the LDim to the value in the new units. This ensures that if the value of an LDim is 1 ft and the units are changed to in , the value is changed to 12. User-Defined Type Validation It is possible to insert a user-defined type value into a column without using the Parse method implemented in the user-defined type. This is done by just inserting a binary number directly into the column. Doing this

Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Adult Web Hosting services

Bookmark the permalink.

Comments are closed.