Exemple #1
0
        protected override Expression VisitInsert(InsertCommandExpression insert)
        {
            var oInsert = insert as OInsertCommandExpression;
            if (oInsert == null) return base.VisitInsert(insert);

            var table = (IdentifiableExpression)this.Visit(oInsert.Identifiable);
            var assignments = this.VisitFieldAssignments(oInsert.Assignments);
            var projection = this.VisitProjection(oInsert.Projection);
            return this.UpdateInsert(oInsert, table, assignments, (ProjectionExpression)projection);
        }
 protected virtual Expression VisitInsert(InsertCommandExpression insert)
 {
     var table = (IdentifiableExpression)this.Visit(insert.Identifiable);
     var assignments = this.VisitFieldAssignments(insert.Assignments);
     return this.UpdateInsert(insert, table, assignments);
 }
Exemple #3
0
 protected override Expression VisitInsert(InsertCommandExpression insert)
 {
     this.Write("INSERT INTO ");
     this.WriteIdentifiableName(insert.Identifiable.Name);
     this.Write("(");
     for (int i = 0, n = insert.Assignments.Count; i < n; i++)
     {
          FieldAssignment ca = insert.Assignments[i];
         if (i > 0) this.Write(", ");
         this.WriteFieldName(ca. Field.Name);
     }
     this.Write(")");
     this.WriteLine(Indentation.Same);
     this.Write("VALUES (");
     for (int i = 0, n = insert.Assignments.Count; i < n; i++)
     {
          FieldAssignment ca = insert.Assignments[i];
         if (i > 0) this.Write(", ");
         this.Visit(ca.Expression);
     }
     this.Write(")");
     return insert;
 }
 protected virtual InsertCommandExpression UpdateInsert(InsertCommandExpression insert, IdentifiableExpression table, IEnumerable<FieldAssignment> assignments)
 {
     if (table != insert.Identifiable || assignments != insert.Assignments)
     {
         return new InsertCommandExpression(table, assignments);
     }
     return insert;
 }
Exemple #5
0
            protected virtual void VisitInsertThing(InsertCommandExpression insert)
            {
                this.Write("INSERT INTO ");
                this.WriteIdentifiableName(insert.Identifiable.Entity.StorageClass);

                this.Write("(");
                for (int i = 0, n = insert.Assignments.Count; i < n; i++)
                {
                    FieldAssignment ca = insert.Assignments[i];
                    if (i > 0) this.Write(", ");
                    this.WriteFieldName(ca.Field.Name);
                }
                this.Write(")");
                this.WriteLine(Indentation.Same);
                this.Write("VALUES (");
                for (int i = 0, n = insert.Assignments.Count; i < n; i++)
                {
                    FieldAssignment ca = insert.Assignments[i];
                    if (i > 0) this.Write(", ");
                    this.Visit(ca.Expression);
                }
                this.Write(") RETURN @this");
            }
Exemple #6
0
 protected virtual void VisitInsertAssociation(InsertCommandExpression insert)
 {
     this.Write("CREATE EDGE ");
     this.WriteIdentifiableName(insert.Identifiable.Entity.StorageClass);
     this.Write(" FROM ");
     this.Visit(insert.Assignments.Single(fa => fa.Field.Name.Equals("out")).Expression);
     this.Write(" TO ");
     this.Visit(insert.Assignments.Single(fa => fa.Field.Name.Equals("in")).Expression);
     if (insert.Assignments.Count > 2)
     {
         this.Write(" SET ");
         bool comma = false;
         foreach (var assignment in insert.Assignments.Where(fa => fa.Field.Name != "out" && fa.Field.Name != "in"))
         {
             if (comma) this.Write(", ");
             this.Visit(assignment.Field);
             this.Write(" = ");
             if (assignment.Expression is ConstantExpression)
             {
                 this.Write(((ConstantExpression)assignment.Expression).Value.ToOrientValueString(assignment.Field.Type));
             }
             else
             {
                 this.Visit(assignment.Expression);
             }
             comma = true;
         }
     }
 }
Exemple #7
0
 protected override Expression VisitInsert(InsertCommandExpression insert)
 {
     if (insert.Identifiable.Entity.EntityType.Implements<IAssociation>())
     {
         VisitInsertAssociation(insert);
     }
     else if (insert.Identifiable.Entity.EntityType.Implements<IThing>())
     {
         VisitInsertThing(insert);
     }
     return insert;
 }
 protected virtual bool CompareInsert(InsertCommandExpression x, InsertCommandExpression y)
 {
     return this.Compare(x.Identifiable, y.Identifiable)
         && this.CompareFieldAssignments(x.Assignments, y.Assignments);
 }
 protected override Expression VisitInsert(InsertCommandExpression insert)
 {
     return base.VisitInsert(insert);
 }