Exemple #1
0
        private T InvokeUpdateOrInsert <T>(Func <IRepository <T>, Func <T, T> > func, T ent)
            where T : class
        {
            try
            {
                if (ValidationRulesEngine != null)
                {
                    ValidationRulesEngine.ValidateOrThrow(ent);
                }
                var rep = RecordCaseUnitOfWork.GetRepository <T>();
                return(func(rep)(ent));
            }
            catch (DbEntityValidationException ex)
            {
                StringBuilder sb = new StringBuilder();


                ex.EntityValidationErrors.ForEachInEnumerable(failure =>
                {
                    sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType());
                    foreach (var error in failure.ValidationErrors)
                    {
                        sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                        sb.AppendLine();
                    }
                });

                // Add the original exception as the innerException
                throw new DbEntityValidationException("Entity Validation Failed - errors follow:\n" + sb, ex);
            }
        }
 public override void Setup(ValidationRulesEngine engine)
 {
     engine.AddRule(new EntityNamingRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerSubclassRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerConcreteClassRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerHierarchyRule());
     engine.AddRule(new AllPropertiesHaveADataTypeRule());
 }
 public override void Setup(ValidationRulesEngine engine)
 {
     engine.AddRule(new EntityNamingRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerSubclassRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerConcreteClassRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerHierarchyRule());
     engine.AddRule(new AllPropertiesHaveADataTypeRule());
 }
        public CollectionsContext(string collectionsMetadataFilename)
        {
            this.collectionsMetadataFilename = collectionsMetadataFilename;

            var ValidationRulesEngine = new ValidationRulesEngine();

            ValidationRulesEngine.AddValidation(PredicateBuilder.True <CollectionMetadata>().And(c => !string.IsNullOrWhiteSpace(c.Name)), "Collection name required.", "Name");
            ViewModelBaseValidating.AddValidationRulesEngine(ValidationRulesEngine);
        }
Exemple #5
0
        public BusinessContext(IUnitOfWork recordCaseUnitOfWork)
        {
            RecordCaseUnitOfWork  = recordCaseUnitOfWork;
            ValidationRulesEngine = new ValidationRulesEngine();
            ValidationRulesEngine.AddValidation(PredicateBuilder.True <Location>().And(l => l.ParentLocation != null), "Location must have parent.");
            ViewModelBaseValidating.AddValidationRulesEngine(ValidationRulesEngine);


            FileFormatParserProvider = new FileFormatParserProvider();
            FileFormatParserProvider.Add(MediaFormatExtension.Mp3, new FileFormatParserMp3());
        }
Exemple #6
0
 public override void Setup(ValidationRulesEngine engine)
 {
     engine.AddRule(new EntityNamingRule());
     engine.AddRule(new DatabaseNamingRule());
     engine.AddRule(new AllColumnsHaveADataTypeRule());
     engine.AddRule(new AllPropertiesHaveADataTypeRule());
     engine.AddRule(new AllComponentPropertiesHaveADataTypeRule());
     engine.AddRule(new CheckEntityComponentsRule());
     engine.AddRule(new CheckSchemaAgainstRealDatabaseRule(_database));
     engine.AddRule(new CheckReferenceCollectionTypeRule());
     engine.AddRule(new CheckLazyPropertiesHaveLazyEntityRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerConcreteClassRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerHierarchyRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerSubclassRule());
 }
Exemple #7
0
        public void SetUp()
        {
            mappingSet = new MappingSetImpl();
            engine     = new ValidationRulesEngine(mappingSet);

            rule1   = MockRepository.GenerateMock <IValidationRule>();
            rule2   = MockRepository.GenerateMock <IValidationRule>();
            result1 = new ValidationResult(rule1);
            result2 = new ValidationResult(rule2);

            rule1.Stub(r => r.Run(mappingSet)).Return(result1);
            rule2.Stub(r => r.Run(mappingSet)).Return(result2);

            engine.AddRule(rule1);
            engine.AddRule(rule2);
        }
 public override void Setup(ValidationRulesEngine engine)
 {
     engine.AddRule(new EntityNamingRule());
     engine.AddRule(new DatabaseNamingRule());
     engine.AddRule(new CheckAllPropertiesMappedRule());
     engine.AddRule(new AllPrimaryColumnsUsedRule());
     engine.AddRule(new AllPropertiesHaveADataTypeRule());
     engine.AddRule(new AllColumnsHaveADataTypeRule());
     engine.AddRule(new AllComponentPropertiesHaveADataTypeRule());
     engine.AddRule(new AllEntitiesHaveAPrimaryKeyRule());
     engine.AddRule(new CheckEntityComponentsRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerConcreteClassRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerHierarchyRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerSubclassRule());
     engine.AddRule(new AllReferencesHaveBackingDataRule());
     engine.AddRule(new AllRelationshipsHaveValidKeys());
     engine.AddRule(new CheckInheritanceClassesAreNotRelated());
 }
 public override void Setup(ValidationRulesEngine engine)
 {
     engine.AddRule(new EntityNamingRule());
     engine.AddRule(new DatabaseNamingRule());
     engine.AddRule(new CheckAllPropertiesMappedRule());
     engine.AddRule(new AllPrimaryColumnsUsedRule());
     engine.AddRule(new AllPropertiesHaveADataTypeRule());
     engine.AddRule(new AllColumnsHaveADataTypeRule());
     engine.AddRule(new AllComponentPropertiesHaveADataTypeRule());
     engine.AddRule(new AllEntitiesHaveAPrimaryKeyRule());
     engine.AddRule(new CheckEntityComponentsRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerConcreteClassRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerHierarchyRule());
     engine.AddRule(new CheckEntityInheritanceForTablePerSubclassRule());
     engine.AddRule(new AllReferencesHaveBackingDataRule());
     engine.AddRule(new AllRelationshipsHaveValidKeys());
     engine.AddRule(new CheckInheritanceClassesAreNotRelated());
 }
 public void Setup()
 {
     valEngine = new ValidationRulesEngine();
 }