What is the best pattern, using breeze, to validate a Save on the server side, which must query the database, and have it "bubble" down to the client?
The server side validation has to query the database to determine if the save is valid, i.e:
C# psuedo-code:
int count = _contextProvider.Context.MyObject.Where(x => x.Something == 1).Count();
if(count != 0) {
throw new Exception("Cannot delete My Object, records exist");
}
Ideally, I would like to be able to just do something like this on the JavaScript client -
entity.entityAspect.validateEntity();
and have it trigger the server side validation (but am open to all suggestions!)
I also need this to prevent SaveChanges from occurring due to the entity being in an invalid state (even without manually calling validateEntity).