Example #1
0
 public virtual bool ResetToDefaultValue(object instance, string field) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     Net.Vpc.Upa.Record r = (Net.Vpc.Upa.Record)instance;
     if (r.IsSet(field))
     {
         r.Remove(field);
         return(true);
     }
     return(false);
 }
 public virtual void BeforePersist(Net.Vpc.Upa.Record record, Net.Vpc.Upa.Persistence.EntityExecutionContext context) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     if (new System.Nullable <bool>(false).Equals(context.GetConnection().GetProperty(identityConstraintsEnabledProperty)))
     {
         return;
     }
     context.AddGeneratedValue(field.GetName(), field.GetDataType());
     //manual id values are ignored
     record.Remove(field.GetName());
 }
Example #3
0
        public virtual Net.Vpc.Upa.Record CreateInitializedRecord()
        {
            object o = CreateObject <R>();

            Net.Vpc.Upa.Record r = CreateRecord();
            r.SetAll(ObjectToRecord(o, false));
            foreach (Net.Vpc.Upa.Field field in entity.GetFields())
            {
                if (field.IsId() && (field.GetModifiers().Contains(Net.Vpc.Upa.FieldModifier.PERSIST_FORMULA) || field.GetModifiers().Contains(Net.Vpc.Upa.FieldModifier.PERSIST_SEQUENCE)))
                {
                    r.Remove(field.GetName());
                }
                else
                {
                    object df = field.GetDefaultValue();
                    if (df != null)
                    {
                        r.SetObject(field.GetName(), df);
                    }
                }
            }
            return(r);
        }
Example #4
0
 public virtual void SetRecordId(Net.Vpc.Upa.Record record, object id) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     System.Collections.Generic.IList <Net.Vpc.Upa.Field> f = GetEntity().GetPrimaryFields();
     if (id == null)
     {
         foreach (Net.Vpc.Upa.Field aF in f)
         {
             record.Remove(aF.GetName());
         }
         return;
     }
     object[] uk = IdToKey(id).GetValue();
     if ((f).Count > 0)
     {
         if (uk.Length != (f).Count)
         {
             throw new System.Exception("key " + id + " could not denote for entity " + GetEntity().GetName() + " ; got " + uk.Length + " elements instread of " + (f).Count);
         }
         for (int i = 0; i < (f).Count; i++)
         {
             record.SetObject(f[i].GetName(), uk[i]);
         }
     }
 }
 public virtual void BeforePersist(Net.Vpc.Upa.Record record, Net.Vpc.Upa.Persistence.EntityExecutionContext context) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     record.Remove(field.GetName());
     record.SetObject(field.GetName(), GetNewValue(field, record, context));
 }