Exemple #1
0
        private string ValidatePerson(Person p)
        {
            DbEntityValidationResult results;
            string sError = string.Empty;
            using ( ComunContext context = new ComunContext() ) {
                results = context.Entry(p).GetValidationResult();
            }

            foreach ( var error in results.ValidationErrors ) {
                sError += error.PropertyName + " : " + error.ErrorMessage;
            }

            return sError;
        }
Exemple #2
0
        private string ValidatePersonProperty(Person p)
        {
            ICollection<DbValidationError> results;
            string sError = string.Empty;
            using ( var context = new ComunContext() ) {
                results = context.Entry(p).Property(a => a.Name).GetValidationErrors();
            }
            foreach ( DbValidationError item in results ) {
                sError += item.PropertyName + " : " + item.ErrorMessage;
            }

            return sError;
        }