title: Null Conditional operator inside SelectMany - still getting NullReferenceException
body: <h1>Accepted Answer @rob</h1>
  
  <p>I needed and a <code>.Where()</code> Clause/Operator  </p>
  
  <h2>Bonus points to @juharr for the direct answer to a misguided question</h2>
  
  <pre><code>List&lt;Guid&gt; ExistingChildrenIDsFromParentsIcollectionJoinParentChildM2M =
          this.parent
          .SelectMany(
              p =&gt; p.joinParentChildM2M?
              .Select(jpc =&gt; jpc.ChildID)
              ?? new List&lt;Guid&gt; {Guid.Empty} //tried similar, but didn't understand the type needs of .SelectMany
              )
          .ToList();
  </code></pre>
  
  <h2>Original Question:</h2>
  
  <p>I'm about 10searches/40results in the hole and getting nowhere on this... TIA!</p>
  
  <p>This statement is throwing NullReferenceException:<br>
  (p.joinParentChildM2M is sometimes initialized null sometimes not)  </p>
  
  <pre><code>List&lt;Guid&gt; ExistingChildrenIDsFromParentsIcollectionJoinParentChildM2M =
          this.parent
          .SelectMany(
              p =&gt; p.joinParentChildM2M? //shouldn't this Null Conditional Operator break the chain?
              .Select(jpc =&gt; jpc.ChildID)
              )
          .ToList()
          ??
          GuidEmptyList();
  </code></pre>
  
  <p>I've tried:<br>
   - moving the Coalesce ?? inside the SelectMany Parens()<br>
   - adding DefaultIfEmpty (realizing empty is different than Null, but worth a shot)<br>
   - adding another Null Conditional to <code>.Select(jpc =&gt; jpc?.ChildID)??Guid.Empty</code></p>
  
  <p>Here's the rest of the code:<br>
  (BTW: I'm fully open to other better ways to initilize by DAOParent class; but definitely want to learn proper Null Conditional syntax in this situation)  </p>
  
  <pre><code>public class Parent
      {
      public Guid parentID {get; set;}
      //Other Properties...
  
      //one-way NavigationProperties
      public ICollection&lt;JoinParentChildM2M&gt; joinParentChildM2M { get; set; }
      }
  
  public class JoinParentChildM2M
      {
      public Guid JoinID {get; set;}
      public Guid ParentID {get; set;}
      public Guid ChildID {get; set;}
      }
  
  public class Child
      {
      public Guid childID {get; set;}
      //Other class Properties...
  
      //one-way NavigationProperties
      public ICollection&lt;JoinParentChildM2M&gt; joinParentChildM2M { get; set; }
  
      }
  
  
  public class DAOParent
      {
      private dbContext _db;
      public IList&lt;Parent&gt; parents {get; set;}
      public IList&lt;Child&gt; children {get; set;}
      //Note: there is no IList&lt;JoinParentChildM2M&gt;, but parents contains an ICOllection&lt;JoinParentChildM2M&gt;
      //Other class Properties...
  
      public DAOParent( dbContext db , ParentIDList ParentIDList)
          {
          //set this._db, etc
          // this.parents will initialize null
          LoadAllChildrenOfParents()
          }
  
      public DAOParent( dbContext db , ParentIDList ParentIDList, DAOParent existingParents)
          {
          //set this.dbcontext, set this.parents to existingParents, etc
          // this.parents will initialize as non-empty objects
          LoadAllChildrenOfParents()
          }
  
      private void LoadAllChildrenOfParents()
          {
  
          //Before I grab new "Child" entities from the db 
          //I want to exclude existing ones already loaded in my POCO
          List&lt;Guid&gt; ExistingChildrenIDsFromParentsIcollectionJoinParentChildM2M =
                  this.parent
                  .SelectMany(
                      p =&gt; p.joinParentChildM2M? //shouldn't this Null Conditional Operator break the chain?
                      .Select(jpc =&gt; jpc.ChildID)
                      )
                  .ToList()
                  ??
                  GuidEmptyList();
          }
  
      private List&lt;Guid&gt; GuidEmptyList()
          {
          List&lt;Guid&gt; g = new List&lt;Guid&gt; { Guid.Empty };
          return g;
          }
  
  
          //More code to finish initializing or updating DAOParent...
          }
      }
  </code></pre>