Exemplo n.º 1
0
        public void ReadWrite()
        {
            using (var s = OpenSession())
            {
                var docEntity = new XmlDocClass {
                    Id = 1
                };
                docEntity.Document = new XmlDocument();
                docEntity.Document.LoadXml("<MyNode>my Text</MyNode>");
                s.Save(docEntity);
                s.Flush();
            }

            using (var s = OpenSession())
            {
                var docEntity = s.Get <XmlDocClass>(1);
                var document = docEntity.Document;
                document.Should().Not.Be.Null();
                document.OuterXml.Should().Contain("<MyNode>my Text</MyNode>");
                var xmlElement = document.CreateElement("Pizza");
                xmlElement.SetAttribute("temp", "calda");
                document.FirstChild.AppendChild(xmlElement);
                s.Save(docEntity);
                s.Flush();
            }
            using (var s = OpenSession())
            {
                var docEntity = s.Get <XmlDocClass>(1);
                docEntity.Document.OuterXml.Should().Contain("Pizza temp=\"calda\"");
                s.Delete(docEntity);
                s.Flush();
            }
        }
Exemplo n.º 2
0
		public void ReadWrite()
		{
			using (var s = OpenSession())
			{
				var docEntity = new XmlDocClass {Id = 1 };
				docEntity.Document = new XmlDocument();
				docEntity.Document.LoadXml("<MyNode>my Text</MyNode>");
				s.Save(docEntity);
				s.Flush();
			}

			using (var s = OpenSession())
			{
				var docEntity = s.Get<XmlDocClass>(1);
				var document = docEntity.Document;
				document.Should().Not.Be.Null();
				document.OuterXml.Should().Contain("<MyNode>my Text</MyNode>");
				var xmlElement = document.CreateElement("Pizza");
				xmlElement.SetAttribute("temp", "calda");
				document.FirstChild.AppendChild(xmlElement);
				s.Save(docEntity);
				s.Flush();
			}
			using (var s = OpenSession())
			{
				var docEntity = s.Get<XmlDocClass>(1);
				docEntity.Document.OuterXml.Should().Contain("Pizza temp=\"calda\"");
				s.Delete(docEntity);
				s.Flush();
			}
		}
Exemplo n.º 3
0
        public async Task ReadWriteAsync()
        {
            using (var s = OpenSession())
            {
                var docEntity = new XmlDocClass {
                    Id = 1
                };
                docEntity.Document = new XmlDocument();
                docEntity.Document.LoadXml("<MyNode>my Text</MyNode>");
                await(s.SaveAsync(docEntity));
                await(s.FlushAsync());
            }

            using (var s = OpenSession())
            {
                var docEntity = await(s.GetAsync <XmlDocClass>(1));
                var document  = docEntity.Document;
                Assert.That(document, Is.Not.Null);
                Assert.That(document.OuterXml, Does.Contain("<MyNode>my Text</MyNode>"));
                var xmlElement = document.CreateElement("Pizza");
                xmlElement.SetAttribute("temp", "calda");
                document.FirstChild.AppendChild(xmlElement);
                await(s.SaveAsync(docEntity));
                await(s.FlushAsync());
            }
            using (var s = OpenSession())
            {
                var docEntity = await(s.GetAsync <XmlDocClass>(1));
                Assert.That(docEntity.Document.OuterXml, Does.Contain("Pizza temp=\"calda\""));
                await(s.DeleteAsync(docEntity));
                await(s.FlushAsync());
            }
        }
Exemplo n.º 4
0
		public void InsertNullValue()
		{
			using (ISession s = OpenSession())
			{
				var docEntity = new XmlDocClass { Id = 1 };
				docEntity.Document = null;
				s.Save(docEntity);
				s.Flush();
			}

			using (ISession s = OpenSession())
			{
				var docEntity = s.Get<XmlDocClass>(1);
				docEntity.Document.Should().Be.Null();
				s.Delete(docEntity);
				s.Flush();
			}
		}
Exemplo n.º 5
0
        public void InsertNullValue()
        {
            using (ISession s = OpenSession())
            {
                var docEntity = new XmlDocClass {
                    Id = 1
                };
                docEntity.Document = null;
                s.Save(docEntity);
                s.Flush();
            }

            using (ISession s = OpenSession())
            {
                var docEntity = s.Get <XmlDocClass>(1);
                docEntity.Document.Should().Be.Null();
                s.Delete(docEntity);
                s.Flush();
            }
        }
Exemplo n.º 6
0
        public async Task InsertNullValueAsync()
        {
            using (ISession s = OpenSession())
            {
                var docEntity = new XmlDocClass {
                    Id = 1
                };
                docEntity.Document = null;
                await(s.SaveAsync(docEntity));
                await(s.FlushAsync());
            }

            using (ISession s = OpenSession())
            {
                var docEntity = await(s.GetAsync <XmlDocClass>(1));
                Assert.That(docEntity.Document, Is.Null);
                await(s.DeleteAsync(docEntity));
                await(s.FlushAsync());
            }
        }