Example #1
0
        public static Movie Read(string MovieTitle)
        {
            using (var session = NHibernateHelpers.OpenSession())
            {
                Movie MovieQuery = new Movie();
                try
                {
                    MovieQuery = (from movie in session.Query <Movie>()
                                  where movie.Title == MovieTitle
                                  select movie).Single();
                }
                catch (Exception exception)
                {
                    return(new Movie());
                }

                //NhQueryProvider.cs

                MessageBox.Show("Read Movie: " + MovieQuery.Title);
                return(MovieQuery);
            }
        }
Example #2
0
 private static ISessionFactory CreateSessionFactory() {
     var configuration = new Configuration();
     //here we add all hbm.xml mapping into configuration
     NHibernateHelpers.AddMapping(configuration);
     return configuration.BuildSessionFactory();
 }