This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, Along with the automatic tracking of the creation and update time I'd like to add info of which user created/updated the entity. It seems it would be possible to implement OnSaving to do this, but hooking up the same OnSaving to 30+ entities seems a bit awkward. Is there a better way to be able to hook into the UoW instead to just have the code updating the user fields in one place for all entities? Thanks, Patrik |
|
|
Hi, I maybe missing the point, but if you have typical audit fields on your entities and dB tables (CreatedBy, CreatedDate, ModifiedBy, ModifiedDate) wouldn't you have these fields set in code for INSERTs and Modified fields set for UPDATE save operations, thus tracking the creation and update details? I was poking around this area the other day, and with dB triggers controlling these values I see your point with 30+ saves: http://www.mindscape.co.nz/forums/Thread.aspx?ThreadID=3306 Cheers, |
|
|
I could use OnSave for every entity to accomplish it, granted - I'm just wondering if there'd be a way to not have to do it separately for every type of entity. I'll have a relatively large number of entities and there's a simple way of having automatic CreatedOn and UpdatedOn built into lightspeed, but not for keeping user info in the same way. I'm looking for a way simple way of accomplishing that. |
|
|
You could use a common base class: public class UserTrackingEntity<TId> : Entity<TId> { then: public class SomeBusinessEntity : UserTrackingEntity<int> { To use a common base class in the designer, either: (a) create the base class in the designer and use concrete table inheritance; or (b) create the base class in code, import it into the designer as an External Class Reference, and set each entity's Base Class using the drop-down instead of an inheritance arrow. The advantage of the second approach is that it avoids lots of inheritance arrows if you have a lot of entities, but the downside is that you will get warnings during designer sync telling you that fields in the base class will not be synchronised. |
|