Click here to Skip to main content
15,672,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello good night guys okay? I have a difficulty in creating a class to list properties. The structure would be the one below?
public class Order
     public string orderNumber {get; set; }
     public DateTime orderDate {get; set; }
     private DateTime RequiredDate {get; set; }
     private DateTime ShippedDate {get; set; }
     public int CustomerNumber {get; set; }
     public bool status {get; set; }
     public string comments {get; set; }
     private IEnumerable<orderdetail> OrderDetail;

     public virtual IEnumerable<orderdetail> OrderDetails
         get {return OrderDetail; }
         set {OrderDetail = value; }

     public Order ()
         OrderDetail = new List<orderdetail> ();

If so, how do I fill it? Does anyone have any examples?
Updated 19-Jun-15 20:43pm
Mostafa Asaduzzaman 19-Jun-15 20:34pm    
rewrite this line : private IEnumerable OrderDetail;
to private IEnumerable<orderdetails> _orderDetails = new IEnumerable<orderdetails>()
and then
public virtual IEnumerable OrderDetails
get {return _orderDetails ; }
set {_orderDetails = value; }
Thyago Analista 19-Jun-15 21:38pm    
Ok thank's. And could spend example of how to fill this property using an SQL query with Inner Join, for example:
myConnection = new SqlConnection (ConnString); myConnection.Open (); MySqlDataAdapter connection adapter = new SqlDataAdapter ("select * O., D. *" + "Orders from the" + "INNER JOIN OrderDetails D" + "ON O.orderNumber = D.orderNumber" myConnection); connection Adapter.Fill (DataTable Daybase);

1 solution

Have a look here: Walkthrough: Creating Your Own Collection Class[^] and change the code as is provided there.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900