示例#1
0
        protected override void OnSetUp()
        {
            using (ISession session = OpenSession())
                using (ITransaction transaction = session.BeginTransaction())
                {
                    var bobsConnection = new Connection
                    {
                        Address        = "test.com",
                        ConnectionType = "http",
                        PortName       = "80"
                    };
                    var e1 = new Person
                    {
                        Name       = "Bob",
                        Connection = bobsConnection
                    };
                    session.Save(e1);

                    var sallysConnection = new Connection
                    {
                        Address        = "test.com",
                        ConnectionType = "http",
                    };
                    var e2 = new Person
                    {
                        Name       = "Sally",
                        Connection = sallysConnection
                    };
                    session.Save(e2);

                    var cachedNullConnection = new Connection
                    {
                        Address        = "test.com",
                        ConnectionType = "http",
                    };
                    var cachedNullConnectionPerson = new CachedPerson
                    {
                        Name       = "CachedNull",
                        Connection = cachedNullConnection
                    };
                    var cachedNotNullConnection = new Connection
                    {
                        Address        = "test.com",
                        ConnectionType = "http",
                        PortName       = "port"
                    };
                    var cachedNotNullConnectionPerson = new CachedPerson
                    {
                        Name       = "CachedNotNull",
                        Connection = cachedNotNullConnection
                    };
                    session.Save(cachedNullConnectionPerson);
                    session.Save(cachedNotNullConnectionPerson);

                    session.Flush();
                    transaction.Commit();
                    session.Evict(typeof(CachedPerson));
                }
        }
示例#2
0
		protected override void OnSetUp()
		{
			using (ISession session = OpenSession())
			using (ITransaction transaction = session.BeginTransaction())
			{
				var bobsConnection = new Connection
					{
						Address = "test.com",
						ConnectionType = "http",
						PortName = "80"
					};
				var e1 = new Person
					{
						Name = "Bob", 
						Connection = bobsConnection
					};
				session.Save(e1);

				var sallysConnection = new Connection
					{
						Address = "test.com",
						ConnectionType = "http",
					};
				var e2 = new Person
					{
						Name = "Sally", 
						Connection = sallysConnection
					};
				session.Save(e2);

				var cachedNullConnection = new Connection
				{
					Address = "test.com",
					ConnectionType = "http",
				};
				var cachedNullConnectionPerson = new CachedPerson
				{
					Name = "CachedNull",
					Connection = cachedNullConnection
				};
				var cachedNotNullConnection = new Connection
				{
					Address = "test.com",
					ConnectionType = "http",
					PortName = "port"
				};
				var cachedNotNullConnectionPerson = new CachedPerson
				{
					Name = "CachedNotNull",
					Connection = cachedNotNullConnection
				};
				session.Save(cachedNullConnectionPerson);
				session.Save(cachedNotNullConnectionPerson);

				session.Flush();
				transaction.Commit();
				session.Evict(typeof(CachedPerson));
			}
		}