O'Reilly logo

NHibernate 3 Beginner's Guide by Gabriel N. Schenker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – Creating the reports

Now that we have prepared the system, we are ready to generate some reports based on the data just persisted in the database using the LINQ to NHibernate provider.

  1. First, implement the method QueryData in the Program class, as shown in the following code snippet:
    private static void QueryData(ISessionFactory factory)
    {
      using (var session = factory.OpenSession())
      using (var tx = session.BeginTransaction())
      {
        PrintListOfStars(session);
        PrintListOfBigBlueStars(session);
        PrintSumOfStarMassPerClass(session);
        PrintListOfHabitablePlanets(session);
        tx.Commit();
      }
    }
  2. Note how this method creates a session, a transaction, and, inside the transaction, calls four reporting methods, passing the session object to each of them. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required