Question : Can a property be added to each property in a collection class

Hi All,

I am creating a separate class for each table in my database as well as the class I use for navigation through my forms (only contains gid).

I would like to keep track of each property(column) of a data collection record by setting it to modified 0 or 1.

Can a property be added to the property caccountid in the code for example?  

Such as if laccount[i].caccountid.lchanged == 1  ....

I can set a record level property such as lchanged, ladded, ldeleted as I did in the attached code, but I want to get more detailed.

I know OnPropertyChanged is callled, but I can not figure out how to make it useful for me at a property/column level.

My plan is to build a SQL statement on the fly to only update columns that actually been modified instead of updating every column in the table if one column changes.

Is this even necessary or is updating all columns if only one column is changed common practice in .Net?

My guess is that the code generated by the .Net SQL adapters update all columns if only one column is modifiied.

Suggestions are welcome if this is reality or folly.

Thank you,

Chris W.
631-521-9100
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
IN FORM
<        public ObservableCollection laccountsnav;
        public ObservableCollection laccount;
>

using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.ComponentModel;
using System.Windows;
using System;

namespace CollectAppWpf
{
    public class TBAccount
    {

        private string connMain = Properties.Settings.Default.collect1ConnectionString;
        private string connSys = Properties.Settings.Default.ffCollectsysConnectionString;
       
        
        public class Account : INotifyPropertyChanged
        {
            #region INotifyPropertyChanged Members

            public event PropertyChangedEventHandler PropertyChanged;
            private void OnPropertyChanged(PropertyChangedEventArgs e)
            {
                if (this.PropertyChanged != null)
                {
                    PropertyChanged(this, e);
                    this.lchanged = true;
                }
            }
            #endregion

            private string _gaccountid;
            public string gaccountid
            {
                get { return _gaccountid; }
                set
                {
                    _gaccountid = value;
                    OnPropertyChanged(new PropertyChangedEventArgs("gaccountid"));
                }
            }

            private string _caccountid;
            public string caccountid
            {
                get { return _caccountid; }
                set
                {
                    _caccountid = value;
                    OnPropertyChanged(new PropertyChangedEventArgs("caccountid"));
                }
            }

            private string _gclientid;
            public string gclientid
            {
                get { return _gclientid; }
                set
                {
                    _gclientid = value;
                    OnPropertyChanged(new PropertyChangedEventArgs("gaccountid"));
                }
            }

            private string _ccompanyname;
            public string ccompanyname
            {
                get { return _ccompanyname; }
                set
                {
                    _ccompanyname = value;
                    OnPropertyChanged(new PropertyChangedEventArgs("ccompanyname"));
                }
            }

            private string _csiccodeid;
            public string csiccodeid
            {
                get { return _csiccodeid; }
                set
                {
                    _csiccodeid = value;
                    OnPropertyChanged(new PropertyChangedEventArgs("csiccodeid"));
                }
            }

            private string _ckey;
            public string ckey
            {
                get { return _ckey; }
                set { _ckey = value; }
            }

            private string _caddr1;
            public string caddr1
            {
                get { return _caddr1; }
                set
                {
                    _caddr1 = value;
                    OnPropertyChanged(new PropertyChangedEventArgs("caddr1"));
                }
            }

            private System.Nullable _tlcall;
            public System.Nullable tlcall
            {
                get
                {
                    return this._tlcall;
                }
                set
                {
                    if ((this._tlcall != value))
                    {
                        this._tlcall = value;
                        OnPropertyChanged(new PropertyChangedEventArgs("tlcall"));
                    }
                }
            }

            private bool _lchanged;
            public bool lchanged
            {
                get { return _lchanged; }
                set { _lchanged = value; }
            }

            private bool _ladded;
            public bool ladded
            {
                get { return _ladded; }
                set { _ladded = value; }
            }

            private bool _ldeleted;
            public bool ldeleted
            {
                get { return _ldeleted; }
                set { _ldeleted = value; }
            }

            public Account(string _gaccountid, string _caccountid, string _gclientid,
               string _ccompanyname, string _csiccodeid, string _ckey, string _caddr1,
                DateTime _tlcall, bool _lchanged, bool _ladded, bool _ldeleted)
            {
                gaccountid = _gaccountid;
                caccountid = _caccountid;
                gclientid = _gclientid;
                ccompanyname = _ccompanyname;
                csiccodeid = _csiccodeid;
                ckey = _ckey;
                caddr1 = _caddr1;
                tlcall = _tlcall;
                lchanged = _lchanged;
                ladded = _ladded;
                ldeleted = _ldeleted;
            }


        } // account class


        public class AccountNav
        {
            private string _gaccountid;
            public string gaccountid
            {
                get { return _gaccountid; }
                set { _gaccountid = value; }
            }

            private string _caccountid;
            public string caccountid
            {
                get { return _caccountid; }
                set { _caccountid = value; }
            }

            private string _clname;
            public string clname
            {
                get { return _clname; }
                set { _clname = value; }
            }

            private string _cfname;
            public string cfname
            {
                get { return _cfname; }
                set { _cfname = value; }
            }

            private string _ckey;
            public string ckey
            {
                get { return _ckey; }
                set { _ckey = value; }
            }

            public AccountNav(string _gaccountid, string _caccountid, string _clname, string _cfname,
                string _ckey)
            {
                gaccountid = _gaccountid;
                caccountid = _caccountid;
                clname = _clname;
                cfname = _cfname;
                ckey = _ckey;
            }

        } // accountnav class

    }
}

Answer : Can a property be added to each property in a collection class

Instead of adding a property to the ID you can add a property to the class..wont that work?
I am not sure if your code is autogenerated. and how you are populating the classes... if you can give that info there is chance of a better solution.

if laccount[i].caccountidChanged == 1  ...
Random Solutions  
 
programming4us programming4us