/// <summary> /// Gets the value of one of this object's properties. /// </summary> public virtual object GetValue(Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants field, object defaultValue) { if (field == Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.CustomerId) { return(this.CustomerId); } if (field == Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.FirstName) { return(this.FirstName); } if (field == Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.LastName) { return(this.LastName); } if (field == Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.CreatedBy) { return((this.CreatedBy == null) ? defaultValue : this.CreatedBy); } if (field == Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.CreatedDate) { return((this.CreatedDate == null) ? defaultValue : this.CreatedDate); } if (field == Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.ModifiedBy) { return((this.ModifiedBy == null) ? defaultValue : this.ModifiedBy); } if (field == Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.ModifiedDate) { return((this.ModifiedDate == null) ? defaultValue : this.ModifiedDate); } throw new Exception("Field '" + field.ToString() + "' not found!"); }
/// <summary> /// Gets the maximum size of the field value. /// </summary> public static int GetMaxLength(Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants field) { switch (field) { case Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.CustomerId: return(0); //Type=Int case Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.FirstName: return(50); case Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.LastName: return(50); } return(0); }
/// <summary> /// Gets the system type of a field on this object /// </summary> public static System.Type GetFieldType(Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants field) { if (field.GetType() != typeof(Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants)) { throw new Exception("The field parameter must be of type 'Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants'."); } switch ((Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants)field) { case Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.CustomerId: return(typeof(int)); case Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.FirstName: return(typeof(string)); case Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.LastName: return(typeof(string)); } return(null); }
/// <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(Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants field, object newValue, bool fixLength) { if (field == Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.CustomerId) { throw new Exception("Field '" + field.ToString() + "' is a primary key and cannot be set!"); } else if (field == Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.FirstName) { this.FirstName = GlobalValues.SetValueHelperInternal((string)newValue, fixLength, GetMaxLength(field)); } else if (field == Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants.LastName) { this.LastName = GlobalValues.SetValueHelperInternal((string)newValue, fixLength, GetMaxLength(field)); } else { throw new Exception("Field '" + field.ToString() + "' not found!"); } }
/// <summary> /// Returns the actual database name of the specified field. /// </summary> internal static string GetDatabaseFieldName(Acme.TestProject.EFDAL.Entity.Customer.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(Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants field, object newValue) { SetValue(field, newValue, false); }
/// <summary> /// Gets the value of one of this object's properties. /// </summary> public virtual object GetValue(Acme.TestProject.EFDAL.Entity.Customer.FieldNameConstants field) { return(GetValue(field, null)); }