tags:

views:

20

answers:

0

Can this linq query be made more concise and improved? And can someone explain the original as well as an refactored version:

Owners.GroupJoin (OwnerSubs, 
                  tl => tl.Unq, 
                  j => j.Unq, 
                  (tl, tl_j) => new  
              {
                  tl = tl, 
                  tl_j = tl_j
              }
                  )
                  .Where (temp0 => (temp0.tl.Id == "123"))
                  .SelectMany (temp0 => temp0.tl_j.DefaultIfEmpty (), 
                          (temp0, j) => new  
                      {
                      Id = temp0.tl.Id, 
                      Business = temp0.tl.Business, 
                      Unq = j.Unq
                      }
                  )

Also, this pulls back a bunch of duplicates unless I add a Distinct()? Is there way to avoid using the Distinct?