Click here to Skip to main content
15,880,651 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi
I am using below code to copy data.

SQL
elements = this.Where(el => !el.Key.StartsWith("."))
                .ToDictionary(el => el.Key, el => el.Value
                    .ToDictionary(p => p.Key, p => p.Value));



It throws error if key already added. I used Distinct() method too. But no luck.

Can you please any body help me out.

Thanks in advance
Posted
Comments
Herman<T>.Instance 18-Jan-13 9:12am    
firest check with Any if it exists
fjdiewornncalwe 18-Jan-13 9:15am    
+5 from me. (You should add it as the answer)
Herman<T>.Instance 18-Jan-13 9:25am    
thanks
Andreas Gieriet 18-Jan-13 9:46am    
Maybe off-topic: you say "copy data". You do not copy the leaf data, you only refer to them assuming they are reference types.
Andi

1 solution

first check with Any() if it exists
 
Share this answer
 
Comments
fjdiewornncalwe 18-Jan-13 9:33am    
My 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900