c# - How to remove duplicate record using linq? -


i have list of list , want remove duplicate list. data stored in list format ienumerable<ienumerable<string>> tabledata if consider table value, parent list rows , child list values of every column. want delete duplicate rows. below table value duplicate.

list<list<string>> ls = new list<list<string>>(); ls.add(new list<string>() { "1", "a" }); ls.add(new list<string>() { "2", "b" }); ls.add(new list<string>() { "3", "c" }); ls.add(new list<string>() { "4", "a" }); ls.add(new list<string>() { "5", "a" }); ls.add(new list<string>() { "6", "d" }); ienumerable<ienumerable<string>> tabledata = ls;  var abc = tabledata.selectmany(p => p).distinct();   ///not work 

after operation, want abc should tabledata format

ls.add(new list<string>() { "1", "a" }); ls.add(new list<string>() { "2", "b" }); ls.add(new list<string>() { "3", "c" });    ls.add(new list<string>() { "6", "d" }); 

tabledata.groupby(q => q.skip(1).first()).select(q => q.first()) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -