public void validateRemoteSystemId() {
NSArray<Category> categories = SCEOFetcher.objectsMatchingKeyAndValue(editingContext(), Category.class, _Category.REMOTE_SYSTEM_ID_KEY, remoteSystemId(), EOFetcher.DBEC);
if (categories.count() > 1)
throw new NSValidation.ValidationException("Category Remote System Id must be unique.", this, REMOTE_SYSTEM_ID_KEY);
}
This works really well if there is already one in the DB with a value of say "123" and I try to add with with a value of "123".
This does not work if I try to add two at the same time with a value of "567", it allows them both through.
Does anyone have a strategy to catch uniqueness at the EOF level?
Or, is it fine to just rely on the DB throwing an SQLException and catch that after ec().saveChanges() ?
(I feel like letting that happen is bad, and might leave EOF in an un-happy state - is there any chance of that?)
Thanks again,
-Dan Grec