c# tik4net 3.3.0 How do I convert '/ip ipsec remote-peer remove [ find id="blah" ]' to c#?

Hi,

Searching through the forum I can’t seem to find any previous post regarding to the question in the topic.
This is the command I’m running at the terminal

/ip ipsec remote-peer remove [ find id=“blah” ]

I’m using tik4net 3.3.0 and using it in Visual Studio and writing C# code.

Among many things I’ve tried, I’m pasting in my last attempt.

            ITikCommand printcmd = connection.CreateCommandAndParameters("/ip/ipsec/remote-peer/remove");
            printcmd.AddParameter("=find", "");
            printcmd.AddParameter("Id", "blah");

I know above code is wrong… (I had to try:P) but you get the picture.

So, how should I go about doing this ?

Only print command supports query words, so split your program into a print with query then iterate the result.

  var cmd = conn.CreateCommandAndParameters("/ip/ipsec/remote-peers/print");
  cmd.AddParameter("id", "blah");
  cmd.AddParameter(".proplist", ".id", TikCommandParameterFormat.NameValue);
  var list = cmd.ExecuteList();

  foreach (var item in list)
  {
    conn.CreateCommandAndParameters("/ip/ipsec/remote-peers/remove", ".id", item.GetId()).ExecuteNonQuery();
  }