Adapter, LLBLGEN Pro v.4.2
Hi,
I have following issue when saving modified entity incl related entities without refetch
adapter.SaveEntity(CurrentEntity,
False,
parUpdateRestriction,
True)
Say I have USER entity having ROLES
USER entity has validator checking before saving that user has assigned at least one active role.
When saving new USER entity, it works fine.
Firstly user is validated (if having at least 1 active role - this related entity is not saved yet)
Then USER is saved
Then its ROLES are validated and saved
Now I want to modify user role AND ALSO modify USER property like eg. password
Now the order of saving is changed, first related ROLES entities then USER entity:
First USER.ROLES are validated and saved (and not refetched)
Then USER is validated, but exception is raised when validating if USER entity has at least one active role by LINQ statement
...User2Roles.Where(Function(c) c.IsDeletedOn Is Nothing).Count = 0
because Role(1..n) is OutOfSync, therefore C.IsDeleted is OutOfSync, because any ROLE was saved before USER validation and not refetched as SaveEntity refetch parameter was false
I know that simple solution is to change SaveEntity refetch parametr to TRUE, but this is just workaround as do not need refetch.
There is clear reason why new USER entity is saved first, then its ROLES.
Why this saving sequence is changed when saving modified USER entity, first saving related entities and then USER entity?