Example #1
0
 public virtual Net.Vpc.Upa.Expressions.Insert AddQuery(Net.Vpc.Upa.Expressions.Insert other)
 {
     if (other == null)
     {
         return(this);
     }
     if (other.entity != null)
     {
         entity = (Net.Vpc.Upa.Expressions.EntityName)other.entity.Copy();
     }
     for (int i = 0; i < (other.fields).Count; i++)
     {
         Set(other.GetField(i).GetName(), other.GetFieldValue(i).Copy());
     }
     return(this);
 }
 public virtual void Insert(Net.Vpc.Upa.Entity entity, Net.Vpc.Upa.Record originalRecord, Net.Vpc.Upa.Record record, Net.Vpc.Upa.Persistence.EntityExecutionContext context) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     Net.Vpc.Upa.PersistenceUnit    pu     = context.GetPersistenceUnit();
     Net.Vpc.Upa.Expressions.Insert insert = new Net.Vpc.Upa.Expressions.Insert().Into(entity.GetName());
     foreach (System.Collections.Generic.KeyValuePair <string, object> entry in record.EntrySet())
     {
         object            @value = (entry).Value;
         string            key    = (entry).Key;
         Net.Vpc.Upa.Field field  = entity.FindField(key);
         //should process specific entity fields
         if ((field.GetDataType() is Net.Vpc.Upa.Types.ManyToOneType))
         {
             Net.Vpc.Upa.Types.ManyToOneType e = (Net.Vpc.Upa.Types.ManyToOneType)field.GetDataType();
             if (e.IsUpdatable())
             {
                 Net.Vpc.Upa.Entity masterEntity = pu.GetEntity(e.GetTargetEntityName());
                 Net.Vpc.Upa.Key    k            = null;
                 if (@value is Net.Vpc.Upa.Record)
                 {
                     k = masterEntity.GetBuilder().RecordToKey((Net.Vpc.Upa.Record)@value);
                 }
                 else
                 {
                     k = masterEntity.GetBuilder().ObjectToKey(@value);
                 }
                 int x = 0;
                 foreach (Net.Vpc.Upa.Field fk in e.GetRelationship().GetSourceRole().GetFields())
                 {
                     insert.Set(fk.GetName(), new Net.Vpc.Upa.Expressions.Param(fk.GetName(), k.GetObjectAt(x)));
                     x++;
                 }
             }
         }
         else
         {
             Net.Vpc.Upa.Expressions.Expression valueExpression = (@value is Net.Vpc.Upa.Expressions.Expression) ? ((Net.Vpc.Upa.Expressions.Expression)((Net.Vpc.Upa.Expressions.Expression)@value)) : new Net.Vpc.Upa.Expressions.Param(field.GetName(), @value);
             insert.Set(key, valueExpression);
         }
     }
     context.GetPersistenceStore().CreateQuery(insert, context).ExecuteNonQuery();
 }
 public virtual Net.Vpc.Upa.Query CreateQuery(Net.Vpc.Upa.Entity e, Net.Vpc.Upa.Expressions.Insert query, Net.Vpc.Upa.Persistence.EntityExecutionContext context) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     return(context.GetPersistenceStore().CreateQuery(e, query, context));
 }
Example #4
0
 protected internal virtual Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInsert CompileInsert(Net.Vpc.Upa.Expressions.Insert v, Net.Vpc.Upa.Impl.Uql.ExpressionTranslationManager manager, Net.Vpc.Upa.Impl.Uql.ExpressionDeclarationList declarations)
 {
     if (v == null)
     {
         return(null);
     }
     Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInsert s = new Net.Vpc.Upa.Impl.Uql.Compiledexpression.CompiledInsert();
     s.Into(v.GetEntity().GetName());
     for (int i = 0; i < v.CountFields(); i++)
     {
         Net.Vpc.Upa.Expressions.Var        fvar   = v.GetField(i);
         Net.Vpc.Upa.Expressions.Expression fvalue = v.GetFieldValue(i);
         Net.Vpc.Upa.Impl.Uql.Compiledexpression.DefaultCompiledExpression vv = manager.TranslateAny(fvalue, declarations);
         s.Set(fvar.GetName(), vv);
     }
     return(s);
 }
Example #5
0
 public Insert(Net.Vpc.Upa.Expressions.Insert other)  : this()
 {
     AddQuery(other);
 }
Example #6
0
 public override Net.Vpc.Upa.Expressions.Expression Copy()
 {
     Net.Vpc.Upa.Expressions.Insert o = new Net.Vpc.Upa.Expressions.Insert();
     o.AddQuery(this);
     return(o);
 }