MikrotikDotNet
MikrotikDotNet copied to clipboard
cmd.ExecuteReaderDynamic() failed when mikrotik returns multiple "keys" in row
...
conn.Open();
var cmd = conn.CreateCommand("ip firewall address-list print");
Result (Raw api response):
!re=.id=*CC997=list=list1=address=192.168.1.1=creation-time=feb/13/2023 02:26:04=dynamic=false=dynamic=false=disabled=false=comment=aaa
!re=.id=*CC998=list=list1=address=192.168.1.0/24=creation-time=feb/13/2023 02:26:04=dynamic=false=dynamic=false=disabled=false=comment=bbb
And when we trying to ExecuteReaderDynamic():
var result = cmd.ExecuteReaderDynamic();
foreach (dynamic ip in result)
Debug.WriteLine($"{ip.Id} - {ip.Address} - {ip.disabled}");
we found that each row have two keys "dynamic" and have exception!
May be we need ExecuteReaderDynamic() bool flag to ignore dublicate keys or some else?
Hi @uom42 , Could you please send the exception details?
System.ArgumentException: 'An item with the same key has already been added. Key: dynamic'
Hi @uom42 , Could you please send the exception details?
Mikrotik raw responce have TWO "dynamic" keys in each row!
Sorry, but we can't ignore duplicates. In this particular example, the meaningful key is the second! We need some way to index duplicate keys and understand that they are duplicates ...