コード例 #1
0
        public virtual string Add(TEntity entityToAdd)
        {
            string messErreur = null;

            try
            {
                context.Entry(entityToAdd).State = EntityState.Added;
                context.SaveChanges();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;

                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        messErreur = messErreur != null ? " , " + validationErrors.Entry.Entity.ToString() : validationErrors.Entry.Entity.ToString();
                    }
                }
            }
            return(messErreur);
        }
コード例 #2
0
 public void Save()
 {
     context.SaveChanges();
 }