Accessing properties from multiple classes
<p>I am creating a web application and I have two classes:</p>

<pre><code>public class MOrderMain
{
    public int ID { get; set; }
    public int CompanyID { get; set; }
    public string CompanyName { get; set; }
    public DateTime OrderDate { get; set; }
    public string BillingName { get; set; }
    public string BillingAddress { get; set; }
    public string DeliveryName { get; set; }
    public string DeliveryAddress { get; set; }
}

public class MOrder
{
   public int ID { get; set; }
   public int OrhID { get; set; }
   public int ProID { get; set; }
   public string Name { get; set; }
   public int Quantity { get; set; }
   public double Rate { get; set; }
   public double Amount { get; set; }
   public int DeliveredQty { get; set; }
}
</code></pre>

<p>I would like to retrieve details from both classes. For example, I want to get
<code>ID</code> and <code>Billing Name</code> from class <code>MorderMain</code> and all the properties from class <code>MOrder</code>. How can I do this?</p>

<p>I am getting the values by database. I have the query but how will I assign the data and how will I retrieve from both?</p>

<pre><code>var mylist = new List&lt;MOrder&gt;();
_con = _db.GetConnection();
if (_con.State.Equals(ConnectionState.Closed))
{
    _con.Open();
}
_cmd = new SqlCommand("Get_All_Order_Details", _con) 
           { CommandType = CommandType.StoredProcedure };
_dr = _cmd.ExecuteReader();

while (_dr.Read())
{
    mylist.Add(new MOrder
    {
        ID = Convert.ToInt32(_dr["ordID"]),
        OrhID = Convert.ToInt32(_dr["orhID"]),
        ProID = Convert.ToInt32(_dr["proID"]),
        Name = _dr["pName"].ToString(),
        Quantity = Convert.ToInt32(_dr["ordQty"]),
        Rate = Convert.ToDouble(_dr["ordRate"]),
        Amount = Convert.ToDouble(_dr["ordAmount"]),
        DeliveredQty = Convert.ToInt32(_dr["ordQtyDelivered"])
     });
}
return mylist;
</code></pre>
