1 private static DynamicParameters ToDynamicParameters(this Dictionary
2 {
3 DynamicParameters output = new DynamicParameters();
4
5 p.ToList().ForEach(x => p.Add(x.Key, x.Value));
6
7 return output;
8 }
When I run this and add a break point it gets to line 5 and then throws an error as per below:
System.ArgumentException: 'An item with the same key has already been added.'
this indicates that a duplicate key exists, but i cant see why as the only one that I have set for autoincrement and unique is the index value.
When I check breakpoints before I see the Values all being added correctly
The @Index is the key that gets incremented and i set the value nthg to Null so it will autoincrement due to null value.
int? nthg = null;
{"@Index", nthg },
{"@Group", tbxGroup.Text },
Everything works fine up the point it reaches the batch of code at the top to line 5 during the break point I check the and it has the vlues of x.Key and x.value as
x.key = @Index
x.value = null
I have tried removing the lines so it would add and auto increment due to them not being present however this comes up with the same error. I am up to the final step to add to sqlite but falling at the last hurdle.? I just dont see how it can be a duplicate entry because this is the very reason i set it to unique and autoincrement so when adding it should find a free number and use this as the index..
Any help very much appreciated..
Laxmidhar SahooPosted Jul 11, 2020, 2:06 AM
RichardPosted Jul 10, 2020, 11:42 AM
Jenith ThakkarPosted Jul 9, 2020, 11:42 PM
As you said
x.key = @Index
where @index is autoincremented so when you debug it shows increamented value like 1,2,3 ?