Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF C# Recording Dependency object data modification
    primarykey
    data
    text
    <p>Am working with dependency objects here, not done much with them before but they look very useful.</p> <p>Basically I've used these objects to be editable in a ListView. However, I then have to write these changes back to SQL. My question is, is there a way to record whether the data has been modified because I don't want to write back to SQL every time someone views the data. Currently I have this:</p> <pre><code>public class KPI : DependencyObject { public static readonly DependencyProperty DepartmentProperty = DependencyProperty.Register("Department", typeof(string), typeof(KPI), new UIPropertyMetadata(null)); public string Department { get { return (string)GetValue(DepartmentProperty); } set { SetValue(DepartmentProperty, value); } } public static readonly DependencyProperty KPINumberProperty = DependencyProperty.Register("KPINumberProperty", typeof(int), typeof(KPI), new UIPropertyMetadata(null)); public int KPINumber { get { return (int)GetValue(KPINumberProperty); } set { SetValue(KPINumberProperty, value); } } } </code></pre> <p>My idea was to have something like:</p> <pre><code> public static bool DataModified = false; public static readonly DependencyProperty DepartmentProperty = DependencyProperty.Register("Department", typeof(string), typeof(KPI), new UIPropertyMetadata(null)); public string Department { get { return (string)GetValue(DepartmentProperty); } set { SetValue(DepartmentProperty, value); DataModified = true; } } </code></pre> <p>So every time something is edited the DataModified property will be set to TRUE, is this a good way of doing it? Or has somebody got a much better way of doing it?</p> <p>Thanks in advance.</p> <p>SumGuy.</p>
    singulars
    1. This table or related slice is empty.
    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