I'm a new user of LLBLGen, and I'm testing / evaluating with a view to deploying it in our next project. In doing so, I'm trying to implement concurrency control on updates to an Entity, but I'm getting inconsistent results.
I've created a predicate to compare the database value of the field I'm changing with the dbValue value of that field in my in-memory Entity. I'm specifying that predicate when calling the Save() method on the Entity.
selectedJournal = New JPSDA.EntityClasses.JournalsEntity(CInt(e.CommandArgument))
Session("selectedJournal") = selectedJournal
...
selectedJournal = CType(Session("selectedJournal"), JPSDA.EntityClasses.JournalsEntity)
selectedJournal.Jnl_Description = txtDescription.Text
Dim concurrencyPredicate As New SD.LLBLGen.Pro.ORMSupportClasses.PredicateExpression
concurrencyPredicate.Add(JPSDA.FactoryClasses.PredicateFactory.CompareValue(JPSDA.JournalsFieldIndex.Jnl_Description, SD.LLBLGen.Pro.ORMSupportClasses.ComparisonOperator.Equal, selectedJournal.Fields(JPSDA.JournalsFieldIndex.Jnl_Description).DbValue))
selectedJournal.Save(concurrencyPredicate)
When testing by changing the value externally between loading the entity and calling the Save(), the Save() is nearly (!) always completing, which it shouldn't.
What appears to be happening is that when I change the value of the property on the Entity instance, its details are being reloaded from the database and so the dbValue value is then up to date, and the concurrency predicate doesn't fail as it should. Stepping through the generated code and referring to the documentation I see that when setting a property value the method SetNewFieldValue() method is called which ...
... will refetch the complete entity's fields from the database if necessary (i.e. the entity is outofsync.).
What does "outofsync" mean in this context and how can I stop it doing that refetch?
Thanks.