WPF / EF & 'Audit' field updates
-
I've got an WPF application (without MVVM or similar), using EF6 (via a OData Webservice) and I wondering whats the best place to update some 'audit' fields. i.e. one entity looks like
public class ActionStatus
{
public int Id {get;set;}
public string ActionStatus{get;set;}[DataType(DataType.Date)]
public DateTime ValidFrom { get; set; }[DataType(DataType.Date)]
public DateTime ValidTo { get; set; }public string ChangedBy { get; set; }
public DateTime ChangedOn { get; set; }
}So on the WPF side I've got this displayed in a DataGrid, which saves the data back etc, all good so far. For the
ChangedBy
andChangedOn
fields I want the 'system' to update these as required. But I'm not sure where it would go! Doing it on the DataGrid events, seems very wrong...far too late, and would need to be done differently if I didn't use a datagrid in the future. The other places, are the OData WebService, the EF Model, or in the entities themselves, or maybe as another part of the 'system', not sure... I presume that this is one of the 'lots of solutions/it depends' type of problems, but some guidance would be helpful. -
I've got an WPF application (without MVVM or similar), using EF6 (via a OData Webservice) and I wondering whats the best place to update some 'audit' fields. i.e. one entity looks like
public class ActionStatus
{
public int Id {get;set;}
public string ActionStatus{get;set;}[DataType(DataType.Date)]
public DateTime ValidFrom { get; set; }[DataType(DataType.Date)]
public DateTime ValidTo { get; set; }public string ChangedBy { get; set; }
public DateTime ChangedOn { get; set; }
}So on the WPF side I've got this displayed in a DataGrid, which saves the data back etc, all good so far. For the
ChangedBy
andChangedOn
fields I want the 'system' to update these as required. But I'm not sure where it would go! Doing it on the DataGrid events, seems very wrong...far too late, and would need to be done differently if I didn't use a datagrid in the future. The other places, are the OData WebService, the EF Model, or in the entities themselves, or maybe as another part of the 'system', not sure... I presume that this is one of the 'lots of solutions/it depends' type of problems, but some guidance would be helpful.That's not an audit-trail, but an indication who made the last change. It'd be an audit if it is a complete trace.
cjb110 wrote:
.far too late, and would need to be done differently if I didn't use a datagrid in the future.
The database - that way it won't matter whether it's a webservice, a WinForm or any other UI/app reading from the database. I'd recommend implementing the bare necessities, and nothing more.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
That's not an audit-trail, but an indication who made the last change. It'd be an audit if it is a complete trace.
cjb110 wrote:
.far too late, and would need to be done differently if I didn't use a datagrid in the future.
The database - that way it won't matter whether it's a webservice, a WinForm or any other UI/app reading from the database. I'd recommend implementing the bare necessities, and nothing more.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
Eddy Vluggen wrote:
That's not an audit-trail, but an indication who made the last change.
heh, I realise, couldn't think of a better term for it.
Eddy Vluggen wrote:
The database - that way it won't matter whether it's a webservice, a WinForm or any other UI/app reading from the database.
As EF is 'creating' my database, and with migrations keeping it up to date, does that mean I add it there as C# code? Or somehow make the migrations side run additional sql to either add trigger or constraint etc?
-
Eddy Vluggen wrote:
That's not an audit-trail, but an indication who made the last change.
heh, I realise, couldn't think of a better term for it.
Eddy Vluggen wrote:
The database - that way it won't matter whether it's a webservice, a WinForm or any other UI/app reading from the database.
As EF is 'creating' my database, and with migrations keeping it up to date, does that mean I add it there as C# code? Or somehow make the migrations side run additional sql to either add trigger or constraint etc?