Linq Group By multiple properties in VB.Net -


i want group on list using vb.net. seems simple can't make work. i've tried:

dim groupedemails = saemails.groupby(function(m) new {m.property1, m.property2, m.property3.subproperty1}) 

i have 6 items in saemails , 2 of items have same property1, property2 , property3. unfortunately, @ runtime i'm still getting 6 items in groupedemails though grouping should reduce count 5.

i've tried statement without "new with" (it still compiles) result same. can't linq entities ("from mail in saemails...") accept use of keyword "group". have imported system.linq.

i happy working use of .tolookup().

the entities similar this:

    namespace     <datacontract()>     public class saemail          <datamember()>         public property property1 integer          <datamember()>         public property property2 string          <datamember()>         public property property3 blah          <datamember()>         public property property4 string      public overrides function equals(obj object) boolean          if obj nothing orelse not me.gettype() obj.gettype()             return false         end if          dim email saemail = ctype(obj, saemail)         return property1 = email.property1 _             andalso property2 = email.property2 _             andalso property1.subproperty1 = email.property3.subproperty1      end function      public overrides function gethashcode() integer         return cint(clng(property1) xor clng(property2) xor clng(property3.subproperty1))     end function      end class      <datacontract()>     public class blah          <datamember()>         public property subproperty1 integer          <datamember()>         public property subproperty2 string      end class end namespace 

ideas?

how creating composite grouping key?

dim groupedemails = saemails.groupby(function(m) string.format("{0}:{1}:{2}", m.property1, m.property2, m.property3.subproperty1)) 

or, using interpolated string when vb14 released in few weeks!:

dim groupedemails = saemails.groupby(function(m) $"{m.property1}:{m.property2}:{m.property3.subproperty1)}") 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -