public void Add(params T[] items)
        {
            foreach (var itemEntity in items)
            {
                MyCareerCloudContext.Entry(itemEntity).State = EntityState.Added;
                MyCareerCloudContext.SaveChanges();
            }

            #region Also_Works
            //// ---Also works
            //if (items != null)
            //{
            //    var dataSet = MyCareerCloudContext.Set<T>();

            //    if (items is IEnumerable)
            //    {
            //        dataSet.AddRange(items);
            //    }
            //    else
            //    {
            //        dataSet.Add(items.Where(p => p != null).FirstOrDefault());
            //    }

            //    MyCareerCloudContext.SaveChanges();
            //}


            //// ---Also works
            //MyCareerCloudContext.Add(items.Where(p => p != null).FirstOrDefault());  //.Set<T>().Add(items.FirstOrDefault());
            //MyCareerCloudContext.SaveChanges();

            #endregion
        }
Example #2
0
        public void Add(params T[] items)
        {
            foreach (T item in items)
            {
                _context.Entry(item).State = EntityState.Added;
            }
            Debug.WriteLine("OK before savechanges");

            //_context.SaveChanges();

            try
            {
                _context.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                    eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                        ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
        }
 public void Add(params T[] items)
 {
     foreach (T record in items)
     {
         _context.Entry(record).State = EntityState.Added;
         _context.SaveChanges();
     }
 }
 public void Add(params T[] items)
 {
     foreach (T item in items)
     {
         _context.Entry(item).State = EntityState.Added;
     }
     _context.SaveChanges();
 }
 public void Add(params T[] items)
 {
     foreach (T poco in items)
     {
         _currentcontext.Entry(poco).State = EntityState.Added;
     }
     _currentcontext.SaveChanges();
 }
Example #6
0
 public void Add(params T[] items)
 {
     foreach (T item in items)
     {
         _context.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Added;
     }
     _context.SaveChanges();
 }
 public void Add(params T[] items)
 {
     foreach (T item in items)
     {
         context.Entry(item).State = System.Data.Entity.EntityState.Added;
     }
     context.SaveChanges();
 }
Example #8
0
 public void Add(params T[] items)
 {
     foreach (T item in items)
     {
         //_context.ApplicantEducations.Add()
         _context.Entry(item).State = EntityState.Added;
     }
     _context.SaveChanges();
 }
Example #9
0
 public void Add(params T[] items)
 {
     foreach (var item in items)
     {
         _context.Entry(item).State = EntityState.Added;
     }
     _context.SaveChanges();
     //throw new NotImplementedException();
 }
Example #10
0
        public void Remove(params T[] items)
        {
            foreach (T item in items)
            {
                _context.Entry(item).State = EntityState.Deleted;
            }

            _context.SaveChanges();
        }
 public void Add(params T[] items)
 {
     foreach (T item in items)
     {
         //Console.WriteLine(_context.Entry(item).State);
         _context.Entry(item).State = EntityState.Added;
     }
     _context.SaveChanges();
 }
        // CRUD operations but with generic implimentation

        public void Add(params SourceType[] pocos)
        {
            //<<#doubt>> : can we pass the SourceType[] is Entry()  and it can find the DbSet property and make chnages to the State ??

            foreach (SourceType poco in pocos)
            {
                _context.Entry(poco).State = EntityState.Added;
            }

            _context.SaveChanges();
        }
 public void Remove(params T[] items)
 {
     using (var context = new CareerCloudContext(_createProxy))
     {
         foreach (T item in items)
         {
             context.Entry(item).State = EntityState.Deleted;
         }
         context.SaveChanges();
     }
 }
Example #14
0
 public void Add(params T[] items)
 {
     using (var context = new CareerCloudContext())
     {
         foreach (T item in items)
         {
             context.Entry(item).State = EntityState.Added;
         }
         context.SaveChanges();
         context.Dispose();
     }
 }
 public void Add(params TPoco[] items)
 {
     try
     {
         using (var context = new CareerCloudContext())
         {
             foreach (var item in items)
             {
                 context.Entry <TPoco>(item).State = EntityState.Added;
                 context.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Exception - {0}", ex);
     }
 }
 public void Save()
 {
     _context.SaveChanges();
 }