/// <summary> /// Ritorna il dato compatibile db /// </summary> /// <param name="obj"></param> /// <returns></returns> public override object GetValueForDb(Objects.Base.DataObjectBase obj) { //Ottiene valore var input = this.GetValue(obj); //Null esce subito if (input == null) { return(input); } //Se il tipo di dato db e' differente dalla property va convertito if (!object.Equals(this.Type, this.Column.DbType)) { return(Convert.ChangeType(input, this.Column.DbType)); } //Se valore da criptare allora esegue if (this.mEncAttr != null) { try { input = this.mEncAttr.Encrypt(obj.GetSlot(), this, input.ToString()); } catch (Exception ex) { throw new ObjectException(Resources.ObjectMessages.Enc_Encrypt_Failure, obj.mClassSchema.ClassName, this.Name, ex.Message); } } //Ritorna valore return(this.IsNull(input) ? null : input); }
/// <summary> /// Ritorna il dato compatibile db /// </summary> /// <param name="input"></param> /// <returns></returns> public override object GetValueForDb(Objects.Base.DataObjectBase obj) { //Ottiene valore var input = obj.mDataSchema.Values[this.PropertyIndex]; //Null esce subito if (input == null) { return(input); } //Converte return(Convert.ChangeType(input, this.Column.DbType)); }
/// <summary> /// Ritorna il valore della proprieta' /// </summary> /// <param name="obj"></param> /// <returns></returns> public override object GetValue(Objects.Base.DataObjectBase obj) { DataObjectBase oRet = obj.mDataSchema.Objects[this.ObjectIndex]; if (oRet == null && !obj.mDataSchema.GetFlagsAll(this.PropertyIndex, DataFlags.ObjLoaded)) { object[] arrPk; if (this.IsMapped) { //Se property 0 e' nulla esce if (this.PropertyMap[0].IsNull(this.PropertyMap[0].GetValue(obj))) { return(null); } //Crea pk come composizione delle proprieta' mappate arrPk = new object[this.PropertyMap.Count]; for (int i = 0; i < this.PropertyMap.Count; i++) { arrPk[i] = this.PropertyMap[i].GetValueForDb(obj); } } else { //Carica PK con valori base proprieta' arrPk = new object[] { this.GetValueForDb(obj) }; } //Se array OK definito ed il primo valore non nullo imposta oggetto if (arrPk != null && arrPk[0] != null) { oRet = obj.GetSlot().LoadObjectInternalByKEY(ClassSchema.PRIMARY_KEY, this.Type, true, arrPk); } //Carica oggetto e imposta come caricato obj.mDataSchema.Objects[this.ObjectIndex] = (DataObjectBase)oRet; //In qualunque caso imposta come caricato obj.mDataSchema.SetFlags(this.PropertyIndex, DataFlags.ObjLoaded, true); } //Caso Base return(oRet); }
/// <summary> /// Ritorna il valore della proprieta' /// </summary> /// <param name="obj"></param> /// <returns></returns> public override object GetValue(Objects.Base.DataObjectBase obj) { //Se null ritorna valore default object oRet = obj.mDataSchema.Values[this.PropertyIndex]; if (oRet == null) { //Se oggetto nuovo o giĆ caricato da db ritorna default if (obj.mDataSchema.ObjectState == EObjectState.New || obj.mDataSchema.GetFlagsAll(this.PropertyIndex, DataFlags.Loaded)) { //Ritorna default return(this.DefaultValue); } //Deve Caricare property obj.LoadPropertyFromDB(this); //Reimposta il valore oRet = obj.mDataSchema.Values[this.PropertyIndex]; } return(oRet); }
public virtual object GetValueForDb(Objects.Base.DataObjectBase obj) { throw new NotImplementedException(string.Format(@"{0}.{1} - GetValueForDb non supportata per il tipo di proprieta'", this.Schema.ClassName, this.Name)); }
public abstract object GetValue(Objects.Base.DataObjectBase obj);