public void SendInsert(string schema, bool isRelational, string collection, object[] rows, string[] columns, bool upsert) { Insert msg = new Mysqlx.Crud.Insert(); msg.Collection = ExprUtil.BuildCollection(schema, collection); msg.DataModel = (isRelational ? DataModel.Table : DataModel.Document); msg.Upsert = upsert; if (columns != null && columns.Length > 0) { foreach (string column in columns) { msg.Projection.Add(new ExprParser(column).ParseTableInsertField()); } } foreach (object row in rows) { Mysqlx.Crud.Insert.Types.TypedRow typedRow = new Mysqlx.Crud.Insert.Types.TypedRow(); object[] fields = row.GetType().IsArray ? (object[])row : new object[] { row }; foreach (object field in fields) { typedRow.Field.Add(ExprUtil.ArgObjectToExpr(field, isRelational)); } msg.Row.Add(typedRow); } _writer.Write(ClientMessageId.CRUD_INSERT, msg); }
public Expr GetValue(UpdateType operationType) { bool evaluateStringExpression = true; if (operationType == UpdateType.ArrayAppend || operationType == UpdateType.ArrayInsert || operationType == UpdateType.ItemSet) { Value = ExprUtil.ParseAnonymousObject(Value) ?? Value; if (Value is string) { try { JsonParser.Parse(Value as string); } catch (Exception) { evaluateStringExpression = false; } } } return(ExprUtil.ArgObjectToExpr(Value, false, evaluateStringExpression)); }
public Expr GetValue() { return(ExprUtil.ArgObjectToExpr(Value, false)); }