public void QueryingWorksWithDetachedCriteria()
        {
            using (new SessionScope())
                CreateLazyBlog();

            var crit = DetachedCriteria.For <Blog>().Add(Expression.Eq("Author", "Mort"));

            using (new StatelessSessionScope())
                Assert.AreEqual(1, AR.FindAll <Blog>(crit).Count());
        }
Exemple #2
0
        public void OperateTheOtherOne()
        {
            using (new SessionScope()) {
                var authors = AR.FindAll <Author>().ToArray();
                Assert.AreEqual(0, authors.Length);
                CreateAuthor();
            }

            using (var scope = new SessionScope()) {
                Assert.AreEqual(1, scope.Count <Author>());
            }
        }
Exemple #3
0
        public void OperateOne()
        {
            using (new SessionScope()) {
                var blogs = AR.FindAll <Blog>().ToArray();

                Assert.AreEqual(0, blogs.Length);

                CreateBlog();
            }

            using (new SessionScope()) {
                var blogs = AR.FindAll <Blog>().ToArray();
                Assert.AreEqual(1, blogs.Length);
            }
        }
Exemple #4
0
        public void SessionsAreDifferent()
        {
            using (new SessionScope())
            {
                var blog   = new Blog();
                var author = new Author();

                AR.FindAll <Blog>();
                AR.FindAll <Author>();

                Assert.AreNotSame(blog.GetCurrentSession(), author.GetCurrentSession());
                Assert.AreNotEqual(
                    blog.GetCurrentSession().Connection.ConnectionString,
                    author.GetCurrentSession().Connection.ConnectionString);
            }
        }