Breeze.ContextProvider.BreezeMetadataValidator.ValidateEntities C# (CSharp) Method

ValidateEntities() public method

Validate all the entities in the saveMap.
Contains all the EntityErrors. Only thrown if throwIfInvalid is true.
public ValidateEntities ( Dictionary saveMap, bool throwIfInvalid ) : List
saveMap Dictionary Map of type to entities.
throwIfInvalid bool If true, throws an EntityErrorsException if any entity is invalid
return List
    public List<EntityError> ValidateEntities(Dictionary<Type, List<EntityInfo>> saveMap, bool throwIfInvalid) {
      var entityErrors = new List<EntityError>();
      foreach (var kvp in saveMap) {

        foreach (var entityInfo in kvp.Value) {
          ValidateEntity(entityInfo, entityErrors);
        }
      }
      if (throwIfInvalid && entityErrors.Any()) {
          throw new EntityErrorsException(entityErrors);
      }
      return entityErrors;
    }

Usage Example

Example #1
0
        protected override Dictionary<Type, List<EntityInfo>> BeforeSaveEntities(Dictionary<Type, List<EntityInfo>> saveMap) {
          var meta = this.GetMetadata();
          var bvalidator = new BreezeMetadataValidator(this, meta);
          bvalidator.ValidateEntities(saveMap, true);

          DataAnnotationsValidator.AddDescriptor(typeof(Customer), typeof(CustomerMetaData));
          var validator = new DataAnnotationsValidator(this);
          validator.ValidateEntities(saveMap, true);

          return base.BeforeSaveEntities(saveMap);
        }