示例#1
0
        public void CanHandleNullEntityInList()
        {
            using (ISession sess = OpenSession())
            using (ITransaction tx = sess.BeginTransaction())
            {
                Employee e = new Employee();
                PrimaryProfession ppc = new PrimaryProfession();
				sess.Save(e);
            	sess.Save(ppc);
            	sess.Flush();

				WantedProfession wanted = new WantedProfession();
            	wanted.Id = 15;
				wanted.Employee = e;
				wanted.PrimaryProfession = ppc;

            	sess.Save(wanted);

				tx.Commit();
            }

            using (ISession sess = OpenSession())
            {
            	ICriteria criteria = sess.CreateCriteria(typeof(Employee));
            	criteria.CreateCriteria("Primaries", JoinType.LeftOuterJoin);
				criteria.CreateCriteria("Secondaries", JoinType.LeftOuterJoin);
            	criteria.List();
            }


        	using (ISession sess = OpenSession())
            {
				sess.Delete("from WantedProfession");
				sess.Flush();
				sess.Delete("from PrimaryProfession");
                sess.Flush();
				sess.Delete("from Employee");
                sess.Flush();
            }
        }
示例#2
0
        public void CanHandleNullEntityInList()
        {
            using (ISession sess = OpenSession())
                using (ITransaction tx = sess.BeginTransaction())
                {
                    Employee          e   = new Employee();
                    PrimaryProfession ppc = new PrimaryProfession();
                    sess.Save(e);
                    sess.Save(ppc);
                    sess.Flush();

                    WantedProfession wanted = new WantedProfession();
                    wanted.Id                = 15;
                    wanted.Employee          = e;
                    wanted.PrimaryProfession = ppc;

                    sess.Save(wanted);

                    tx.Commit();
                }

            using (ISession sess = OpenSession())
            {
                ICriteria criteria = sess.CreateCriteria(typeof(Employee));
                criteria.CreateCriteria("Primaries", JoinType.LeftOuterJoin);
                criteria.CreateCriteria("Secondaries", JoinType.LeftOuterJoin);
                criteria.List();
            }


            using (ISession sess = OpenSession())
            {
                sess.Delete("from WantedProfession");
                sess.Flush();
                sess.Delete("from PrimaryProfession");
                sess.Flush();
                sess.Delete("from Employee");
                sess.Flush();
            }
        }
示例#3
0
        public async Task CanHandleNullEntityInListAsync()
        {
            using (ISession sess = OpenSession())
                using (ITransaction tx = sess.BeginTransaction())
                {
                    Employee          e   = new Employee();
                    PrimaryProfession ppc = new PrimaryProfession();
                    await(sess.SaveAsync(e));
                    await(sess.SaveAsync(ppc));
                    await(sess.FlushAsync());

                    WantedProfession wanted = new WantedProfession();
                    wanted.Id                = 15;
                    wanted.Employee          = e;
                    wanted.PrimaryProfession = ppc;

                    await(sess.SaveAsync(wanted));

                    await(tx.CommitAsync());
                }

            using (ISession sess = OpenSession())
            {
                ICriteria criteria = sess.CreateCriteria(typeof(Employee));
                criteria.CreateCriteria("Primaries", JoinType.LeftOuterJoin);
                criteria.CreateCriteria("Secondaries", JoinType.LeftOuterJoin);
                await(criteria.ListAsync());
            }


            using (ISession sess = OpenSession())
            {
                await(sess.DeleteAsync("from WantedProfession"));
                await(sess.FlushAsync());
                await(sess.DeleteAsync("from PrimaryProfession"));
                await(sess.FlushAsync());
                await(sess.DeleteAsync("from Employee"));
                await(sess.FlushAsync());
            }
        }