title: Looking for assistance diagnosing SQL IndexOutOfRangeException & SQLException
body: <p>I am trying to return a list of customers with their associated products or associated payment types. I am able to return the customers by themselves, but not with either embedded/expanded information requests. I am rather new to coding, so the voluminous error messages do not mean much to me, as I don't know how to interpret them. I received the IndexOutOfRangeException : Product Id when trying to return the customer's products and a SQLException : Incorrect Syntax Near '.' for the payment types. I think I have named and referenced all the data fields and aliases properly, but I just can't find out what I'm overlooking.</p>
  
  <p>Code for customers with products:</p>
  
  <pre><code>string command = "";
  
  string customerColumns = @"
         SELECT c.Id AS 'CustomerId', 
         c.FirstName AS 'CustomerFirstName', 
         c.LastName AS 'CustomerLastName',
         c.AccountCreated AS 'DateJoined', 
         c.LastActive AS 'LastActive',
         c.Archived"; 
  
         string customerTable = "FROM Customer c";
  
  
  if (include == "products")
    {
         string productColumns = @"
         pt.Name AS 'ProductType',
         p.Id,
         p.Title AS 'ProductName', 
         p.Description AS 'ProductDescription', 
         p.Price AS 'ProductPrice',
         p.Quantity AS 'QuantityAvailable',
         p.Archived";
  
         string productTables = @"
         JOIN Product p ON p.CustomerId = c.Id 
         JOIN ProductType pt ON pt.Id = p.ProductTypeId";
  
         command = $@"{customerColumns}, 
                   {productColumns} 
                   {customerTable} 
                   {productTables}";
     }
  
  ...
  
  cmd.CommandText = command;
         SqlDataReader reader = cmd.ExecuteReader();
         List&lt;Customer&gt; Customers = new List&lt;Customer&gt;();
  
         while (reader.Read())
           {
  
           Customer currentCustomer = new Customer
             {
              Id = reader.GetInt32(reader.GetOrdinal("CustomerId")),
              FirstName = reader.GetString(reader.GetOrdinal("CustomerFirstName")),
              LastName = reader.GetString(reader.GetOrdinal("CustomerLastName")),
              AccountCreated = reader.GetDateTime(reader.GetOrdinal("DateJoined")),
              LastActive = reader.GetDateTime(reader.GetOrdinal("LastActive")),
              Archived = reader.GetBoolean(reader.GetOrdinal("Archived"))
             };
  
           if (include == "products")
  
             {
              Product currentProduct = new Product
              {
               Id = reader.GetInt32(reader.GetOrdinal("Id")),
               Title = reader.GetString(reader.GetOrdinal("ProductName")),
               Description = reader.GetString(reader.GetOrdinal("ProductDescription")),
               Quantity = reader.GetInt32(reader.GetOrdinal("QuantityAvailable")),
               Price = reader.GetDouble(reader.GetOrdinal("ProductPrice"))
              };
  </code></pre>
  
  <p>Current code is shown above.</p>
  
  <p>Anyone that can guide me or offer insight as to how to understand or figure out the error messages is greatly appreciated! Thank you!</p>