Created
September 9, 2012 12:14
-
-
Save davybrion/3684023 to your computer and use it in GitHub Desktop.
code snippets for "Bulk Data Operations With NHibernate's Stateless Sessions" post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var testObjects = CreateTestObjects(500000); | |
| var stopwatch = new Stopwatch(); | |
| stopwatch.Start(); | |
| using (ITransaction transaction = Session.BeginTransaction()) | |
| { | |
| foreach (var testObject in testObjects) | |
| { | |
| Session.Save(testObject); | |
| } | |
| transaction.Commit(); | |
| } | |
| stopwatch.Stop(); | |
| var time = stopwatch.Elapsed; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <property name="adonet.batch_size">100</property> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var testObjects = CreateTestObjects(500000); | |
| var stopwatch = new Stopwatch(); | |
| stopwatch.Start(); | |
| using (IStatelessSession statelessSession = sessionFactory.OpenStatelessSession()) | |
| using (ITransaction transaction = statelessSession.BeginTransaction()) | |
| { | |
| foreach (var testObject in testObjects) | |
| { | |
| statelessSession.Insert(testObject); | |
| } | |
| transaction.Commit(); | |
| } | |
| stopwatch.Stop(); | |
| var time = stopwatch.Elapsed; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment