public void DynamicFetch()
        {
            using (ISession s = OpenSession())
            using (ITransaction tx = s.BeginTransaction())
            {
                DateTime now = DateTime.Now;
                User me = new User("me");
                User you = new User("you");
                Resource yourClock = new Resource("clock", you);
                Task task = new Task(me, "clean", yourClock, now); // :)
                s.Save(me);
                s.Save(you);
                s.Save(yourClock);
                s.Save(task);
                tx.Commit();
            }

            using (IStatelessSession ss = sessions.OpenStatelessSession())
            using (ITransaction tx = ss.BeginTransaction())
            {
                ss.BeginTransaction();
                Task taskRef =
                    (Task)ss.CreateQuery("from Task t join fetch t.Resource join fetch t.User").UniqueResult();
                Assert.True(taskRef != null);
                Assert.True(NHibernateUtil.IsInitialized(taskRef));
                Assert.True(NHibernateUtil.IsInitialized(taskRef.User));
                Assert.True(NHibernateUtil.IsInitialized(taskRef.Resource));
                Assert.False(NHibernateUtil.IsInitialized(taskRef.Resource.Owner));
                tx.Commit();
            }

            cleanup();
        }
예제 #2
0
		public Task(User user, string description, Resource resource, DateTime dueDate, DateTime? startDate, DateTime? completionDate)
		{
			this.user = user;
			this.resource = resource;
			this.description = description;
			this.dueDate = dueDate;
			this.startDate = startDate;
			this.completionDate = completionDate;
		}
예제 #3
0
		public Task(User user, string description, Resource resource, DateTime dueDate) 
            : this(user, description, resource, dueDate, null, null)
		{
		}