Beispiel #1
0
        public void SaveManyTestObjs(List <Bodies> newObjs)
        {
            var transaction = _dbSession.BeginTransaction();

            foreach (Bodies o in newObjs)
            {
                //_dbSession.Merge(o);
                _dbSession.Insert(o);
            }
            transaction.Commit();
        }
        /// <summary>
        /// BulkInsertion Will Be Done On The Table Related To The Class
        /// </summary>
        public static void BulkInsert <T>(List <T> objList)
        {
            using (NHibernate.IStatelessSession session = SessionFactory.GetNewStateLessSession())
            {
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        int count = objList.Count();
                        session.SetBatchSize(count);

                        foreach (var item in objList)
                        {
                            session.Insert(item);
                        }
                        transaction.Commit();
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
        }