RetrieveChanges(out ignoredChanges)
Here's another quick blog about a new ECO IV feature. I asked for this during development because I had a particular problem I had to solve.
My new application has a class named "PlannedCall". When the user logs in they see a list of planned calls that are
A: Active
B: Not already actioned
C: Assigned to the current user, or not assigned to anyone
D: EarliestCallTime <= Today + 1
As time goes on there will be a lot of instances of this class in my DB, so obviously I want to use the OclPSHandle to select my objects otherwise I will end up with a whole load of objects in memory that I do not need. However, when another user actions the planned call the Actioned property becomes true. If I use an ExpressionHandle then this planned call would disappear from the presented list, but with OclPSHandle it will not. This is where the new feature comes in!
When you call PersistenceService.RetrieveChanges a collection of DBChange will be sent to the client from the server. The EcoSpace will inspect this list and create an IChange each time the DBChange refers to an object instance loaded into the EcoSpace cache.
In the past the DBChanges that do not apply were discarded, but now you can get hold of them. Take a look at this:
SelectPlanendCalls will just execute an OclPsHandle...
This will only load objects that meet the correct criteria.
Finally, my expression handle can work on PlannedCall.allLoadedObjects instead of PlannedCall.allInstances - something like this
So now I have the benefit of being able to limit which objects I use by utilising the OclPsHandle, but also the benefit of the list being subscribed to so that changes to my local cache will add/remove rows in the grid displaying the planned calls + the list is updated if someone else updates a planned call.
I've just tested it in my application. I'm so pleased that I felt compelled to tell the world :-)
My new application has a class named "PlannedCall". When the user logs in they see a list of planned calls that are
A: Active
B: Not already actioned
C: Assigned to the current user, or not assigned to anyone
D: EarliestCallTime <= Today + 1
As time goes on there will be a lot of instances of this class in my DB, so obviously I want to use the OclPSHandle to select my objects otherwise I will end up with a whole load of objects in memory that I do not need. However, when another user actions the planned call the Actioned property becomes true. If I use an ExpressionHandle then this planned call would disappear from the presented list, but with OclPSHandle it will not. This is where the new feature comes in!
When you call PersistenceService.RetrieveChanges a collection of DBChange will be sent to the client from the server. The EcoSpace will inspect this list and create an IChange each time the DBChange refers to an object instance loaded into the EcoSpace cache.
In the past the DBChanges that do not apply were discarded, but now you can get hold of them. Take a look at this:
DBChangeCollection ignoredChanges;
EcoSpace.Persistence.RetrieveChanges(ignoredChanges);
//Do what you normally do with the IChange list here!
//Now check if there are relevant changes to objects we have not loaded
int plannedCallClassId =
EcoSpace.TypeSystem.GetClassByType(typeof(PlannedCall)).InternalIndex;
foreach(DBChange currentChange in ignoredChanges)
if (currentChange.ObjectId.ClassId = plannedCallClassId)
{
SelectPlannedCalls();
break;
}
SelectPlanendCalls will just execute an OclPsHandle...
sqlPlannedCalls.Expression = "PlannedCall.allInstances->select(...whatever...)";
sqlPlannedCalls.Execute();
This will only load objects that meet the correct criteria.
Finally, my expression handle can work on PlannedCall.allLoadedObjects instead of PlannedCall.allInstances - something like this
PlannedCall.allLoadedObjects
->select(active)
->select(not actioned)
->select( (assignedTo->isEmpty) or (assignedTo = var_CurrentUser) )
->select(earliestCallTime <= DateTime.Now.AddDays(1))
So now I have the benefit of being able to limit which objects I use by utilising the OclPsHandle, but also the benefit of the list being subscribed to so that changes to my local cache will add/remove rows in the grid displaying the planned calls + the list is updated if someone else updates a planned call.
I've just tested it in my application. I'm so pleased that I felt compelled to tell the world :-)
Comments
I notice this ECOIV example is C#.
Will C# be the dominate language for EcoIV?
What do you need for deployment
OR would ECO be available as a plug in for VS
Pete
Thanks for the answer on ECO with VS.
You said
Quote
I am using ECO IV in VS2005 because I have access to stuff that has not yet been released.
Unquote
Could you possibly tell us when the likely release date of ECO for VS2005 would be...