title: Debugging a complex linq query
body: <p>I am dealing with a complex <code>linq</code> query as shown below which raises <code>System.NullReferenceException</code> during run time. Unfortunately, visual studio does not provide any other info and I am not able to do a <code>QuickWatch</code> on the values to check to see which one is null. Is there a way to debug this kind of queries so that I can see what is wrong ?</p>
  
  <pre><code>var dataSource = (from c in session.Query&lt;PortChannel&gt;()
          select
              new PortChannelData
              {
                  Location = c.Port.MagazineSlot.SiteMagazine.Site.SiteName,
                  MagazineName =
                      String.Format("{0}-{1}", c.Port.MagazineSlot.SiteMagazine.MagazineType.MagazineName,
                          c.Port.MagazineSlot.SiteMagazine.MagazineNo),
                  SlotNo = c.Port.MagazineSlot.SlotNo,
                  PortNo = c.Port.PortNo,
                  Klm = c.Klm,
                  StmNo = c.StmNo,
                  Label = c.SiteName == null ? null : String.Format("{0}_{1}", c.SiteName, c.E1No),
                  ChannelFullName = c.ChannelFullName,
                  BscRncPort = c.BscRncPort,
                  MgwPort = c.MgwPort,
                  ReservedBy = c.ReservedBy,
                  CrossFullName = c.CrossConnection == null ? null : c.CrossConnection.ChannelFullName
              }).ToList();
  }
  </code></pre>