Advertisement
Guest User

Untitled

a guest
Nov 21st, 2011
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using NHibernate.Cfg;
  4. using Eg.Core.Entities;
  5.  
  6. namespace AppPerSession
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             var nhConfig = new Configuration().Configure();
  13.             var sessionFactory = nhConfig.BuildSessionFactory();
  14.             Console.WriteLine("Configured!");
  15.             using (var openSession = sessionFactory.OpenSession())
  16.             {
  17.                 using (var tr = openSession.BeginTransaction())
  18.                 {
  19.                     IEnumerable<Book> bookList = openSession.QueryOver<Book>().List<Book>();
  20.                     foreach (var book in bookList)
  21.                     {
  22.                         Console.WriteLine(book.Name);
  23.                         Console.WriteLine();
  24.                     }
  25.                     tr.Commit();
  26.                 }
  27.             }
  28.         }
  29.     }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement