AcklenAvenue.Data.Sample.ConsoleApp.Program.QueryTheDatabase C# (CSharp) Method

QueryTheDatabase() static private method

static private QueryTheDatabase ( ISessionContainer sessionContainer ) : void
sessionContainer ISessionContainer
return void
        static void QueryTheDatabase(ISessionContainer sessionContainer)
        {
            //you've got to open the session before we can use it
            sessionContainer.OpenSession();

            //using the opened session from the sessionContainer, we can query the database
            List<Account> accounts = sessionContainer.Session.Query<Account>().ToList();
            accounts.ForEach(x => Console.WriteLine(x.Name));

            //afterwards, you need to close the session
            sessionContainer.CloseSession();
        }
    }