Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Class list and properties
    primarykey
    data
    text
    <p>I'm very new to programming so this probably is a silly question for the most of you, but still and since I have already tried to look in Google, here it goes :</p> <p>I created a class with some properties and 2 methods, some of the properties should be for the first method and the other for the second method.</p> <p>both of the methods returns a list and my problem is that both of the lists returns all of the properties. Don't know why since I'am not using all of them in both methods... here is a example:</p> <pre><code>class orders { public string invoiceID { get; set; } public string employee { get; set; } public string store { get; set; } public string client { get; set; } public string invoiceDate { get; set; } public string total { get; set; } public string totalYear { get; set; } public string year { get; set; } public static List&lt;orders&gt; getOrders() { string sSQL = "bla bla bla huge query " DBConnect connect = new DBConnect(); DataTable dt = new DataTable(); dt = connect.getBD(sSQL); List&lt;orders&gt; o = new List&lt;orders&gt;(); for (int i = 0; i &lt; dt.Rows.Count; i++) { orders ord = new orders(); ord.invoiceID = dt.Rows[i]["invoiceid"].ToString(); ord.employee = dt.Rows[i]["empname"].ToString(); ord.store = dt.Rows[i]["storename"].ToString(); ord.client = dt.Rows[i]["clientname"].ToString(); ord.invoiceDate = ((DateTime)dt.Rows[i]["invoicedate"]).ToString("dd-MM-yyyy"); ord.total = dt.Rows[i]["total"].ToString(); o.Add(ord); } return o; </code></pre> <p>so in this method I am not using the public properties year and totalYear, but they still appear in the list :(</p> <p>What am I doing wrong ?</p> <p>Thank in advance and sorry for the noob question.</p> <p>UPDATE 1 (second method)</p> <pre><code> public static List&lt;orders&gt; getTotalYearInvoices() { DateTime date = DateTime.Now; int year = date.Year; List&lt;orders&gt; o = new List&lt;orders&gt;(); for (int i = 2009; i &lt; year; i++) { string sSQL = " another huge query" DBConnect connect = new DBConnect(); DataTable dt = new DataTable(); dt = connect.getBD(sSQL); orders ord = new orders(); ord.year = i.ToString(); for (int j = 0; j &lt; dt.Rows.Count; j++) { ord.totalYear = dt.Rows[j]["total"].ToString(); } o.Add(ord); } return o; } </code></pre>
    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.
 

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