finding a member property of an item in an array
<p>I've passed in the whole <code>sale</code> object into this function. In that <code>sale</code> object, there are many childs e.g. saleOrderItem, Payment, User...  </p>

<p>sale.payment is an array</p>

<p>Question:
1) How do I get the <code>CodeNo</code> from the `sale.payment' object? (as payment is an array)<br>
2) How to get the sale.payment.CourseByTutor.TutorId (as payment is an array)</p>

<pre><code>  public static object GetSalesDataBySaleOrderID(SaleOrder sale)
        {
            return sale.saleOrderItem
                       .Where(s =&gt; s != null)
                       .Select(s =&gt; new { 
                                          Id = s.Id,
                                          Username = sale.User.GetSingleUserById(s.UserId).Name,
                                          Amount = s.Amount,
                                          CodeNo = s.SaleOrder.payment.First().CodeNo,
                                          TutorName = sale.User.GetSingleUserById(s.SaleOrder.payment.FirstOrDefault().CourseByTutor.TutorId).Name,
                                        })
                       .ToList();
        }
</code></pre>

<p>Here is how i bind the value to the object</p>

<pre><code> private void SaveValueToObject()
    {
        saleOrder.UserId = UserInfo.Id;
        saleOrder.Date = DateTime.Now;            

        for (int i = 0; i &lt; dgSale.Rows.Count; i++)
        {
            SaleOrderItem SaleItem = new SaleOrderItem();
            SaleItem.InventoryTypeId = Convert.ToInt32(dgSale.Rows[i].Cells["inventoryTypeId"].Value);
            SaleItem.InventoryOrCourseId = Convert.ToInt32(dgSale.Rows[i].Cells["inventoryId"].Value);
            SaleItem.Qty = Convert.ToInt32(dgSale.Rows[i].Cells["qty"].Value);
            SaleItem.Amount = Convert.ToDecimal(dgSale.Rows[i].Cells["total"].Value);
            SaleItem.UserId = Convert.ToInt32(dgSale.Rows[i].Cells["userId"].Value);
            SaleItem.Discount = Convert.ToDecimal(dgSale.Rows[i].Cells["discount"].Value);
            SaleItem.Remarks = (dgSale.Rows[i].Cells["remark"].Value == null) ? "" : dgSale.Rows[i].Cells["remark"].Value.ToString();
            SaleItem.Status = (int)SaleOrderStatus.Active;
            saleOrder.saleOrderItem[i] = SaleItem;                


            Payment p = new Payment();
            p.PayType = Convert.ToInt32(dgSale.Rows[i].Cells["payType"].Value);
            p.Code = (int)PaymentCode.RCT; // For Receipt prefix
            p.CodeNo = p.GetNewReceiptNo(p.Code); //Check if it is receipt, if yes, Get last Receipt No + 1
            p.UserId = (txtUserId.Text == string.Empty) ? 0 : Convert.ToInt32(txtUserId.Text);
            p.Amount = Convert.ToDecimal(dgSale.Rows[i].Cells["total"].Value);
            p.Remark = (dgSale.Rows[i].Cells["remark"].Value == null) ? "" : dgSale.Rows[i].Cells["remark"].Value.ToString();
            p.PaymentMethodId = saleOrder.PaymentMethodId;
            p.DateIssue = saleOrder.Date;

            p.CourseByTutor.TutorId = Convert.ToInt32(dgSale.Rows[i].Cells["tutorId"].Value);


            saleOrder.payment[i] = p;
        }
    }
</code></pre>
