Hi Guys
I'm using:
VS2005
LLBLGen with Adapter Classes for remoting
Optimistic concurrency by means of Dependency Injection and ConcurrencyPredicateFactories.
My core tables implement the following fields for concurrency purposes.
Created DATETIME
CreatedById INT
Modified DATETIME
ModifiedById INT
Given the following object hierarchy, each object/table implementing the abovementioned fields:
Customer -> Invoice -> InvoiceLine
Ideally I would like to be able to update the Created(ById) and Modified(ById) fields for all New/Dirty entities down the object hierarchy by calling something like the following:
customer.SetUserId(1); // set CreatedById and ModifiedById on the client
customer.SetTimeStamp(DateTime.Now); // set Created and Modified TimeStamp on the remoting server.
Other than looping through each entity and related EntityCollection to set the values,** are there any existing best practices you can recommend for achieving the abovementioned?**
I suppose one could use the concurrency predicate factory for updating the timestamp fields when doing the concurrency checks. However, ideally I would like to specifiy the same date and time for all entities forming part of the same update.
I've also considered using dependency injection for injecting something like a static ConcurrencyManager class that would enable one to update all subscribed entities.
customer.ConcurrencyManager.SetUserId(1);
customer.ConcurrencyManager.SetTimeStamp(DateTime.Now);
// or
ConcurrencyManager.Instance.SetUserId(1); // using Singleton
ConcurrencyManager.Instance.SetTimeStamp(DateTime.Now); // using Singleton
However, I imagine the ConcurrencyManager would then have to be a public property on each of the entities for the injection to work. I must admit, I'm rather new to the whole subject of Dependency Injection and the way that it's implemented in LLBLgen, meaning i'm not altogether sure that this is even possible.
I really look forward to any suggestions.
Thank you
Jean-Paul