c# - Using Linq to group objects that contain a list field -


i have class, let's name myclass, public field of type ilist<anothertype>:

class myclass {     public ilist<anothertype> mylistproperty {get;} } 

i have list of myclass objects in app:

list = new list<myclass>(); 

i want group "list", iorderedenumerable<igrouping<myclass,anothertype>> using linq, used source collectionviewsource , shown user grouped listview. how can this?

in other words, want merge "list" grouped enumerable keys being myclass instances , values being myclass.mylistproperty.

if undestand correctly, you're looking this:

list.selectmany(x => x.mylistproperty.groupby(y => x)); 

this returns ienumerable<igrouping<myclass, anothertype>>. make iorderedenumerable, need add .orderby(x => x.someorderingproperty); @ end.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -