Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since you are retrieving data from both tables in your database but want to combine them in your application, the solution would be to create a single class that contains the data you return from your stored procedure:</p> <pre><code>public class MAllOrderDetails { public int ID { get; set; } public string BillingName { get; set; } // include the other billing details you want here 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>Then, your query changes to filling in a <code>List&lt;MAllOrderDetails&gt;</code>.</p> <p>This leaves your application with only dealing with a collection of a single class with all the data nicely contained in single objects.</p> <pre><code>var mylist = new List&lt;MAllOrderDetails&gt;(); //... while (_dr.Read()) { mylist.Add(new MAllOrderDetails { ID = Convert.ToInt32(_dr["ordID"]), BillingName = _dr["BillingName"].ToString(), // etc. 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"]) }); } </code></pre> <p><strong>Update</strong></p> <p>You could probably get away with this as the closest solution to not creating an additional classes:</p> <pre><code>class MAllOrderDetails { public MOrder Order { get; set; } public MOrderMain OrderMain { get; set; } } </code></pre> <p>I feel, though, that from a maintainability standpoint, this will cause you more headaches than just creating additional classes.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload