public override int GetHashCode() { int hash = 1; if (typePresentCase_ == TypePresentOneofCase.Type) { hash ^= Type.GetHashCode(); } if (find_ != null) { hash ^= Find.GetHashCode(); } if (insert_ != null) { hash ^= Insert.GetHashCode(); } if (update_ != null) { hash ^= Update.GetHashCode(); } if (delete_ != null) { hash ^= Delete.GetHashCode(); } if (stmtExecute_ != null) { hash ^= StmtExecute.GetHashCode(); } hash ^= (int)typePresentCase_; if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void SendExecuteStatement(string ns, string stmt, params KeyValuePair <string, object>[] args) { StmtExecute stmtExecute = new StmtExecute(); stmtExecute.Namespace = ns; stmtExecute.Stmt = ByteString.CopyFromUtf8(stmt); stmtExecute.CompactMetadata = false; if (args != null) { var any = ExprUtil.BuildEmptyAny(Any.Types.Type.Object); foreach (var arg in args) { switch (stmt) { case "drop_collection_index": any.Obj.Fld.Add(CreateObject(arg.Key, arg.Value, false)); break; default: any.Obj.Fld.Add(CreateObject(arg.Key, arg.Value)); break; } } stmtExecute.Args.Add(any); } _writer.Write(ClientMessageId.SQL_STMT_EXECUTE, stmtExecute); }
public void MergeFrom(OneOfMessage other) { if (other == null) { return; } if (other.find_ != null) { if (find_ == null) { find_ = new global::Mysqlx.Crud.Find(); } Find.MergeFrom(other.Find); } if (other.insert_ != null) { if (insert_ == null) { insert_ = new global::Mysqlx.Crud.Insert(); } Insert.MergeFrom(other.Insert); } if (other.update_ != null) { if (update_ == null) { update_ = new global::Mysqlx.Crud.Update(); } Update.MergeFrom(other.Update); } if (other.delete_ != null) { if (delete_ == null) { delete_ = new global::Mysqlx.Crud.Delete(); } Delete.MergeFrom(other.Delete); } if (other.stmtExecute_ != null) { if (stmtExecute_ == null) { stmtExecute_ = new global::Mysqlx.Sql.StmtExecute(); } StmtExecute.MergeFrom(other.StmtExecute); } switch (other.TypePresentCase) { case TypePresentOneofCase.Type: Type = other.Type; break; } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
/// <summary> /// Build the message to be sent to MySQL Server to execute statement "Create" or "Modify" collection with schema options /// </summary> /// <param name="ns">The namespace</param> /// <param name="stmt">The name of the command to be executed on MySql Server</param> /// <param name="args">Array of KeyValuePairs with the parameters required to build the message</param> /// <returns>void.</returns> public void SendExecuteStatementOptions(string ns, string stmt, params KeyValuePair <string, object>[] args) { StmtExecute stmtExecute = new StmtExecute(); stmtExecute.Namespace = ns; stmtExecute.Stmt = ByteString.CopyFromUtf8(stmt); stmtExecute.CompactMetadata = false; if (args != null) { var options = new ObjectField(); var validation = new ObjectField(); var reuse_obj = new ObjectField(); var optionsAny = ExprUtil.BuildEmptyAny(Any.Types.Type.Object); var any = ExprUtil.BuildEmptyAny(Any.Types.Type.Object); var innerAny = ExprUtil.BuildEmptyAny(Any.Types.Type.Object); var reuse_any = ExprUtil.BuildEmptyAny(Any.Types.Type.Object); foreach (var arg in args) { if (arg.Value is Dictionary <string, object> && arg.Key == "options") { foreach (var field in arg.Value as Dictionary <string, object> ) { innerAny.Obj.Fld.Add(CreateObject(field.Key, field.Value)); } } else if (arg.Key == "reuse_existing") { reuse_any = ExprUtil.BuildAny(arg.Value); } else { any.Obj.Fld.Add(CreateObject(arg.Key, arg.Value)); } } options.Key = "options"; validation.Key = "validation"; validation.Value = innerAny; reuse_obj.Key = "reuse_existing"; reuse_obj.Value = reuse_any; optionsAny.Obj.Fld.Add(validation); if (stmt == "create_collection") { optionsAny.Obj.Fld.Add(reuse_obj); } options.Value = optionsAny; any.Obj.Fld.Add(options); stmtExecute.Args.Add(any); } _writer.Write(ClientMessageId.SQL_STMT_EXECUTE, stmtExecute); }
public void SendExecuteStatement(string ns, string stmt, params object[] args) { StmtExecute stmtExecute = new StmtExecute(); stmtExecute.Namespace = ns; stmtExecute.Stmt = ByteString.CopyFromUtf8(stmt); stmtExecute.CompactMetadata = false; if (args != null) { foreach (object arg in args) { stmtExecute.Args.Add(CreateAny(arg)); } } _writer.Write(ClientMessageId.SQL_STMT_EXECUTE, stmtExecute); }
internal StmtExecute CreateExecuteSQLStatement(string stmt, params object[] args) { StmtExecute stmtExecute = new StmtExecute(); stmtExecute.Namespace = "sql"; stmtExecute.Stmt = ByteString.CopyFromUtf8(stmt); stmtExecute.CompactMetadata = false; if (args != null) { foreach (object arg in args) { stmtExecute.Args.Add(CreateAny(arg)); } } return(stmtExecute); }
public void SendCreateCollectionIndexStatement(string ns, string stmt, params KeyValuePair <string, object>[] args) { StmtExecute stmtExecute = new StmtExecute(); stmtExecute.Namespace = ns; stmtExecute.Stmt = ByteString.CopyFromUtf8(stmt); stmtExecute.CompactMetadata = false; if (args != null) { var any = ExprUtil.BuildEmptyAny(Any.Types.Type.Object); var array = new Mysqlx.Datatypes.Array(); foreach (var arg in args) { if (arg.Value is Dictionary <string, object> && arg.Key == "constraint") { var innerAny = ExprUtil.BuildEmptyAny(Any.Types.Type.Object); foreach (var field in arg.Value as Dictionary <string, object> ) { innerAny.Obj.Fld.Add(CreateObject(field.Key, field.Value, field.Key == "member" ? true : false)); } array.Value.Add(innerAny); } else { any.Obj.Fld.Add(CreateObject(arg.Key, arg.Value, false)); } } if (array.Value.Count > 0) { var constraint = new ObjectField(); constraint.Key = "constraint"; var constraintAny = ExprUtil.BuildEmptyAny(Any.Types.Type.Array); constraintAny.Array = array; constraint.Value = constraintAny; any.Obj.Fld.Add(constraint); } stmtExecute.Args.Add(any); } _writer.Write(ClientMessageId.SQL_STMT_EXECUTE, stmtExecute); }
public void SendExecuteSQLStatement(string stmt, params object[] args) { StmtExecute stmtExecute = CreateExecuteSQLStatement(stmt, args); _writer.Write(ClientMessageId.SQL_STMT_EXECUTE, stmtExecute); }