/// <summary> /// Assigns a value to a field on this object. /// </summary> /// <param name="field">The field to set</param> /// <param name="newValue">The new value to assign to the field</param> /// <param name="fixLength">Determines if the length should be truncated if too long. When false, an error will be raised if data is too large to be assigned to the field.</param> public virtual void SetValue(Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants field, object newValue, bool fixLength) { if (field == Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.City) { this.City = GlobalValues.SetValueHelperInternal((string)newValue, fixLength, GetMaxLength(field)); } else if (field == Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.Latitude) { this.Latitude = GlobalValues.SetValueHelperDoubleNullableInternal(newValue); } else if (field == Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.Longitude) { this.Longitude = GlobalValues.SetValueHelperDoubleNullableInternal(newValue); } else if (field == Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.PostalCode) { this.PostalCode = GlobalValues.SetValueHelperInternal((string)newValue, fixLength, GetMaxLength(field)); } else if (field == Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.RowId) { throw new Exception("Field '" + field.ToString() + "' is a primary key and cannot be set!"); } else { throw new Exception("Field '" + field.ToString() + "' not found!"); } }
/// <summary> /// Gets the system type of a field on this object /// </summary> public static System.Type GetFieldType(Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants field) { if (field.GetType() != typeof(Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants)) { throw new Exception("The field parameter must be of type 'Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants'."); } switch ((Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants)field) { case Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.City: return(typeof(string)); case Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.Latitude: return(typeof(double?)); case Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.Longitude: return(typeof(double?)); case Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.PostalCode: return(typeof(string)); case Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.RowId: return(typeof(int)); } return(null); }
/// <summary> /// Gets the maximum size of the field value. /// </summary> public static int GetMaxLength(Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants field) { switch (field) { case Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.City: return(100); case Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.Latitude: return(0); case Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.Longitude: return(0); case Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.PostalCode: return(10); case Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.RowId: return(0); } return(0); }
/// <summary> /// Gets the value of one of this object's properties. /// </summary> public virtual object GetValue(Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants field, object defaultValue) { if (field == Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.City) { return(this.City); } if (field == Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.Latitude) { return((this.Latitude == null) ? defaultValue : this.Latitude); } if (field == Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.Longitude) { return((this.Longitude == null) ? defaultValue : this.Longitude); } if (field == Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.PostalCode) { return(this.PostalCode); } if (field == Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants.RowId) { return(this.RowId); } throw new Exception("Field '" + field.ToString() + "' not found!"); }
/// <summary> /// Returns the actual database name of the specified field. /// </summary> internal static string GetDatabaseFieldName(Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants field) { return(GetDatabaseFieldName(field.ToString())); }
/// <summary> /// Assigns a value to a field on this object. /// </summary> /// <param name="field">The field to set</param> /// <param name="newValue">The new value to assign to the field</param> public virtual void SetValue(Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants field, object newValue) { SetValue(field, newValue, false); }
/// <summary> /// Gets the value of one of this object's properties. /// </summary> public virtual object GetValue(Gravitybox.GeoLocation.EFDAL.Entity.CanadaPostalCode.FieldNameConstants field) { return(GetValue(field, null)); }