当前位置: 首页>>代码示例>>C#>>正文


C# Document.Has方法代码示例

本文整理汇总了C#中Document.Has方法的典型用法代码示例。如果您正苦于以下问题:C# Document.Has方法的具体用法?C# Document.Has怎么用?C# Document.Has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Document的用法示例。


在下文中一共展示了Document.Has方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_create_and_delete_document

        public void Should_create_and_delete_document()
        {
            Database.CreateTestCollection(Database.TestDocumentCollectionName);
            var db = Database.GetTestDatabase();

            // create document object
            var document = new Document()
                .String("foo", "foo string value")
                .Int("bar", 12345);

            // save it to database collection
            db.Document.Create(Database.TestDocumentCollectionName, document);

            // check if it contains data after creation
            Assert.AreEqual(false, document.IsNull("_id"));
            Assert.AreEqual(false, document.IsNull("_key"));
            Assert.AreEqual(false, document.IsNull("_rev"));
            Assert.AreEqual(false, document.IsNull("foo"));
            Assert.AreEqual(false, document.IsNull("bar"));

            Assert.AreEqual(true, document.Has("foo"));
            Assert.AreEqual(true, document.Has("bar"));

            // delete created document
            var isDeleted = db.Document.Delete(document.String("_id"));

            Assert.AreEqual(true, isDeleted);
        }
开发者ID:jocull,项目名称:ArangoDB-NET,代码行数:28,代码来源:ArangoDocumentTests.cs

示例2: Should_create_and_get_document

        public void Should_create_and_get_document()
        {
            Database.CreateTestCollection(Database.TestDocumentCollectionName);
            var db = Database.GetTestDatabase();

            var dateUtcNow = DateTime.UtcNow;
            var unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            TimeSpan span = (dateUtcNow.ToUniversalTime() - unixEpoch);

            // create document object
            var document = new Document()
                .String("foo", "foo string value")
                .Int("bar", 12345)
                .DateTime("dateTime", dateUtcNow);

            // save it to database collection
            db.Document.Create(Database.TestDocumentCollectionName, document);

            // get the very same document from database
            var returnedDocument = db.Document.Get(document.String("_id"));

            // check if created and returned document data are equal

            Assert.AreEqual(false, document.IsNull("_id"));
            Assert.AreEqual(false, document.IsNull("_key"));
            Assert.AreEqual(false, document.IsNull("_rev"));
            Assert.AreEqual(false, document.IsNull("foo"));
            Assert.AreEqual(false, document.IsNull("bar"));
            Assert.AreEqual(false, document.IsNull("dateTime"));
            Assert.AreEqual(false, returnedDocument.IsNull("_id"));
            Assert.AreEqual(false, returnedDocument.IsNull("_key"));
            Assert.AreEqual(false, returnedDocument.IsNull("_rev"));
            Assert.AreEqual(false, returnedDocument.IsNull("foo"));
            Assert.AreEqual(false, returnedDocument.IsNull("bar"));
            Assert.AreEqual(false, returnedDocument.IsNull("dateTime"));

            Assert.AreEqual(document.String("_id"), returnedDocument.String("_id"));
            Assert.AreEqual(document.String("_key"), returnedDocument.String("_key"));
            Assert.AreEqual(document.String("_rev"), returnedDocument.String("_rev"));
            Assert.AreEqual(document.Has("foo"), returnedDocument.Has("foo"));
            Assert.AreEqual(document.String("foo"), returnedDocument.String("foo"));
            Assert.AreEqual(document.Has("bar"), returnedDocument.Has("bar"));
            Assert.AreEqual(document.Int("bar"), returnedDocument.Int("bar"));
            Assert.AreEqual(typeof(long), returnedDocument.Type("dateTime"));
            Assert.AreEqual(typeof(DateTime), returnedDocument.DateTime("dateTime").GetType());
            Assert.AreEqual((long)span.TotalSeconds, document.Long("dateTime"));
            Assert.AreEqual(dateUtcNow.ToString("yyyy-MM-dd HH:mm:ss"), document.DateTime("dateTime").ToString("yyyy-MM-dd HH:mm:ss"));
        }
开发者ID:jocull,项目名称:ArangoDB-NET,代码行数:48,代码来源:ArangoDocumentTests.cs

示例3: Should_create_and_update_and_get_document

        public void Should_create_and_update_and_get_document()
        {
            Database.CreateTestCollection(Database.TestDocumentCollectionName);
            var db = Database.GetTestDatabase();

            // create document object
            var document = new Document()
                .String("foo", "foo string value")
                .Int("bar", 12345);

            // save it to database collection
            db.Document.Create(Database.TestDocumentCollectionName, document);

            // update data in that document
            document.String("baz.foo", "bar string value");

            // update document in database
            var isUpdated = db.Document.Update(document);

            Assert.AreEqual(true, isUpdated);

            // get the very same document from database
            var returnedDocument = db.Document.Get(document.String("_id"));

            // check if the data of updated and returned document are equal
            Assert.AreEqual(false, document.IsNull("_id"));
            Assert.AreEqual(false, document.IsNull("_key"));
            Assert.AreEqual(false, document.IsNull("_rev"));
            Assert.AreEqual(false, document.IsNull("foo"));
            Assert.AreEqual(false, document.IsNull("bar"));
            Assert.AreEqual(false, document.IsNull("baz.foo"));
            Assert.AreEqual(false, returnedDocument.IsNull("_id"));
            Assert.AreEqual(false, returnedDocument.IsNull("_key"));
            Assert.AreEqual(false, returnedDocument.IsNull("_rev"));
            Assert.AreEqual(false, returnedDocument.IsNull("foo"));
            Assert.AreEqual(false, returnedDocument.IsNull("bar"));
            Assert.AreEqual(false, returnedDocument.IsNull("baz.foo"));

            Assert.AreEqual(document.String("_id"), returnedDocument.String("_id"));
            Assert.AreEqual(document.String("_key"), returnedDocument.String("_key"));
            Assert.AreEqual(document.String("_rev"), returnedDocument.String("_rev"));
            Assert.AreEqual(document.Has("foo"), returnedDocument.Has("foo"));
            Assert.AreEqual(document.String("foo"), returnedDocument.String("foo"));
            Assert.AreEqual(document.Has("bar"), returnedDocument.Has("bar"));
            Assert.AreEqual(document.Int("bar"), returnedDocument.Int("bar"));
            Assert.AreEqual(document.Has("baz.foo"), returnedDocument.Has("baz.foo"));
            Assert.AreEqual(document.String("baz.foo"), returnedDocument.String("baz.foo"));
        }
开发者ID:jocull,项目名称:ArangoDB-NET,代码行数:48,代码来源:ArangoDocumentTests.cs

示例4: Should_create_and_replace_and_get_document

        public void Should_create_and_replace_and_get_document()
        {
            Database.CreateTestCollection(Database.TestDocumentCollectionName);
            var db = Database.GetTestDatabase();

            // create document object
            var document = new Document()
                .String("foo", "foo string value")
                .Int("bar", 12345);

            // save it to database collection
            db.Document.Create(Database.TestDocumentCollectionName, document);

            // create new document object
            var newDocument = new Document()
                .String("_id", document.String("_id"))
                .String("baz.foo", "bar string value");

            // replace previously created document with new one
            var isReplaced = db.Document.Replace(newDocument);

            Assert.AreEqual(true, isReplaced);

            // get the very same document from database
            var returnedDocument = db.Document.Get(document.String("_id"));

            // check if the data of replaced and returned document are equal
            Assert.AreEqual(false, document.IsNull("_id"));
            Assert.AreEqual(false, document.IsNull("_key"));
            Assert.AreEqual(false, document.IsNull("_rev"));
            Assert.AreEqual(false, document.IsNull("foo"));
            Assert.AreEqual(false, document.IsNull("bar"));
            Assert.AreEqual(false, newDocument.IsNull("_id"));
            Assert.AreEqual(false, newDocument.IsNull("_key"));
            Assert.AreEqual(false, newDocument.IsNull("_rev"));
            Assert.AreEqual(false, newDocument.IsNull("baz.foo"));
            Assert.AreEqual(false, returnedDocument.IsNull("_id"));
            Assert.AreEqual(false, returnedDocument.IsNull("_key"));
            Assert.AreEqual(false, returnedDocument.IsNull("_rev"));
            Assert.AreEqual(false, returnedDocument.IsNull("baz.foo"));

            Assert.AreEqual(newDocument.String("_id"), returnedDocument.String("_id"));
            Assert.AreEqual(newDocument.String("_key"), returnedDocument.String("_key"));
            Assert.AreEqual(newDocument.String("_rev"), returnedDocument.String("_rev"));
            Assert.AreEqual(newDocument.Has("baz.foo"), returnedDocument.Has("baz.foo"));
            Assert.AreEqual(newDocument.String("baz.foo"), returnedDocument.String("baz.foo"));

            // check if the original data doesn't exist anymore
            Assert.AreEqual(false, newDocument.Has("foo"));
            Assert.AreEqual(false, newDocument.Has("bar"));
            Assert.AreEqual(false, returnedDocument.Has("foo"));
            Assert.AreEqual(false, returnedDocument.Has("bar"));
        }
开发者ID:jocull,项目名称:ArangoDB-NET,代码行数:53,代码来源:ArangoDocumentTests.cs

示例5: Should_create_and_delete_edge

        public void Should_create_and_delete_edge()
        {
            Database.CreateTestCollection(Database.TestDocumentCollectionName);
            Database.CreateTestCollection(Database.TestEdgeCollectionName, ArangoCollectionType.Edge);
            var db = Database.GetTestDatabase();

            // create test documents
            var doc1 = new Document()
                .String("foo", "foo string value 1")
                .Int("bar", 12345);

            var doc2 = new Document()
                .String("foo", "foo string value 2")
                .Int("bar", 54321);

            db.Document.Create(Database.TestDocumentCollectionName, doc1);
            db.Document.Create(Database.TestDocumentCollectionName, doc2);

            // create test edge
            var edge = new Document()
                .String("edgeFoo", "foo string value")
                .Int("edgeBar", 12345);

            edge.String("_from", doc1.String("_id"));
            edge.String("_to", doc2.String("_id"));

            db.Edge.Create(Database.TestEdgeCollectionName, edge);

            // check if it contains data after creation
            Assert.AreEqual(false, edge.IsNull("_id"));
            Assert.AreEqual(false, edge.IsNull("_key"));
            Assert.AreEqual(false, edge.IsNull("_rev"));

            Assert.AreEqual(true, edge.Has("edgeFoo"));
            Assert.AreEqual(true, edge.Has("edgeBar"));

            // delete that document
            var isDeleted = db.Edge.Delete(edge.String("_id"));

            Assert.AreEqual(true, isDeleted);
        }
开发者ID:jsteemann,项目名称:ArangoDB-NET,代码行数:41,代码来源:ArangoEdgeTests.cs

示例6: Should_create_and_update_and_get_edge

        public void Should_create_and_update_and_get_edge()
        {
            Database.CreateTestCollection(Database.TestDocumentCollectionName);
            Database.CreateTestCollection(Database.TestEdgeCollectionName, ArangoCollectionType.Edge);
            var db = Database.GetTestDatabase();

             // create test documents
            var doc1 = new Document()
                .String("foo", "foo string value 1")
                .Int("bar", 12345);

            var doc2 = new Document()
                .String("foo", "foo string value 2")
                .Int("bar", 54321);

            db.Document.Create(Database.TestDocumentCollectionName, doc1);
            db.Document.Create(Database.TestDocumentCollectionName, doc2);

            // create test edge
            var edge = new Document()
                .String("edgeFoo", "foo string value")
                .Int("edgeBar", 12345);

            edge.String("_from", doc1.String("_id"));
            edge.String("_to", doc2.String("_id"));

            db.Edge.Create(Database.TestEdgeCollectionName, edge);

            // update data in that document and update it in database
            edge.String("baz.foo", "bar string value");

            var isUpdated = db.Edge.Update(edge);

            Assert.AreEqual(true, isUpdated);

            // get the very same document from database
            var returnedEdge = db.Edge.Get(edge.String("_id"));

            // check if the data of updated and returned document are equal
            Assert.AreEqual(false, edge.IsNull("_id"));
            Assert.AreEqual(false, edge.IsNull("_key"));
            Assert.AreEqual(false, edge.IsNull("_rev"));
            Assert.AreEqual(false, edge.IsNull("_from"));
            Assert.AreEqual(false, edge.IsNull("_to"));
            Assert.AreEqual(false, edge.IsNull("edgeFoo"));
            Assert.AreEqual(false, edge.IsNull("edgeBar"));
            Assert.AreEqual(false, edge.IsNull("baz.foo"));
            Assert.AreEqual(false, returnedEdge.IsNull("_id"));
            Assert.AreEqual(false, returnedEdge.IsNull("_key"));
            Assert.AreEqual(false, returnedEdge.IsNull("_rev"));
            Assert.AreEqual(false, returnedEdge.IsNull("_from"));
            Assert.AreEqual(false, returnedEdge.IsNull("_to"));
            Assert.AreEqual(false, returnedEdge.IsNull("edgeFoo"));
            Assert.AreEqual(false, returnedEdge.IsNull("edgeBar"));
            Assert.AreEqual(false, returnedEdge.IsNull("baz.foo"));

            Assert.AreEqual(edge.String("_id"), returnedEdge.String("_id"));
            Assert.AreEqual(edge.String("_key"), returnedEdge.String("_key"));
            Assert.AreEqual(edge.String("_rev"), returnedEdge.String("_rev"));
            Assert.AreEqual(edge.Has("edgeFoo"), returnedEdge.Has("edgeFoo"));
            Assert.AreEqual(edge.String("edgeFoo"), returnedEdge.String("edgeFoo"));
            Assert.AreEqual(edge.Has("edgeBar"), returnedEdge.Has("edgeBar"));
            Assert.AreEqual(edge.Int("edgeBar"), returnedEdge.Int("edgeBar"));
            Assert.AreEqual(edge.Has("baz.foo"), returnedEdge.Has("baz.foo"));
            Assert.AreEqual(edge.String("baz.foo"), returnedEdge.String("baz.foo"));
        }
开发者ID:jsteemann,项目名称:ArangoDB-NET,代码行数:66,代码来源:ArangoEdgeTests.cs

示例7: Should_create_and_replace_and_get_edge

        public void Should_create_and_replace_and_get_edge()
        {
            Database.CreateTestCollection(Database.TestDocumentCollectionName);
            Database.CreateTestCollection(Database.TestEdgeCollectionName, ArangoCollectionType.Edge);
            var db = Database.GetTestDatabase();

            // create test documents
            var doc1 = new Document()
                .String("foo", "foo string value 1")
                .Int("bar", 12345);

            var doc2 = new Document()
                .String("foo", "foo string value 2")
                .Int("bar", 54321);

            db.Document.Create(Database.TestDocumentCollectionName, doc1);
            db.Document.Create(Database.TestDocumentCollectionName, doc2);

            // create test edge
            var edge = new Document()
                .String("edgeFoo", "foo string value")
                .Int("edgeBar", 12345);

            edge.String("_from", doc1.String("_id"));
            edge.String("_to", doc2.String("_id"));

            db.Edge.Create(Database.TestEdgeCollectionName, edge);

            // change data in that edge and replaced it in database
            var newEdge = new Document();
            newEdge.String("_id", edge.String("_id"));
            newEdge.String("baz.foo", "bar string value");

            var isReplaced = db.Edge.Replace(newEdge);

            Assert.AreEqual(true, isReplaced);

            // get the very same edge from database
            var returnedEdge = db.Edge.Get(edge.String("_id"));

            // check if the data of replaced and returned edge are equal
            Assert.AreEqual(false, newEdge.IsNull("_id"));
            Assert.AreEqual(false, newEdge.IsNull("_key"));
            Assert.AreEqual(false, newEdge.IsNull("_rev"));
            Assert.AreEqual(true, newEdge.IsNull("_from"));
            Assert.AreEqual(true, newEdge.IsNull("_to"));
            Assert.AreEqual(false, newEdge.IsNull("baz.foo"));
            Assert.AreEqual(false, returnedEdge.IsNull("_id"));
            Assert.AreEqual(false, returnedEdge.IsNull("_key"));
            Assert.AreEqual(false, returnedEdge.IsNull("_rev"));
            Assert.AreEqual(false, returnedEdge.IsNull("_from"));
            Assert.AreEqual(false, returnedEdge.IsNull("_to"));
            Assert.AreEqual(false, returnedEdge.IsNull("baz.foo"));

            Assert.AreEqual(newEdge.String("_id"), returnedEdge.String("_id"));
            Assert.AreEqual(newEdge.String("_key"), returnedEdge.String("_key"));
            Assert.AreEqual(newEdge.String("_rev"), returnedEdge.String("_rev"));
            Assert.AreEqual(newEdge.Has("baz.foo"), returnedEdge.Has("baz.foo"));
            Assert.AreEqual(newEdge.String("baz.foo"), returnedEdge.String("baz.foo"));

            // check if the original data doesn't exist anymore
            Assert.AreEqual(false, newEdge.Has("foo"));
            Assert.AreEqual(false, newEdge.Has("bar"));
            Assert.AreEqual(false, returnedEdge.Has("foo"));
            Assert.AreEqual(false, returnedEdge.Has("bar"));
        }
开发者ID:jsteemann,项目名称:ArangoDB-NET,代码行数:66,代码来源:ArangoEdgeTests.cs

示例8: Should_create_and_get_out_direction_edges

        public void Should_create_and_get_out_direction_edges()
        {
            Database.CreateTestCollection(Database.TestDocumentCollectionName);
            Database.CreateTestCollection(Database.TestEdgeCollectionName, ArangoCollectionType.Edge);
            var db = Database.GetTestDatabase();

            // create test documents
            var doc1 = new Document()
                .String("foo", "foo string value 1")
                .Int("bar", 12345);

            var doc2 = new Document()
                .String("foo", "foo string value 2")
                .Int("bar", 54321);

            db.Document.Create(Database.TestDocumentCollectionName, doc1);
            db.Document.Create(Database.TestDocumentCollectionName, doc2);

            // create test edge
            var edge1 = new Document()
                .String("edgeFoo", "foo string value 1")
                .Int("edgeBar", 12345);

            edge1.String("_from", doc1.String("_id"));
            edge1.String("_to", doc2.String("_id"));

            db.Edge.Create(Database.TestEdgeCollectionName, edge1);

            // create another test edge
            var edge2 = new Document()
                .String("edgeFoo", "foo string value 2")
                .Int("edgeBar", 54321);

            edge2.String("_from", doc2.String("_id"));
            edge2.String("_to", doc1.String("_id"));

            db.Edge.Create(Database.TestEdgeCollectionName, edge2);

            // get only outgoing edges (should be one)
            var outEdges = db.Edge.Get(Database.TestEdgeCollectionName, doc1.String("_id"), ArangoEdgeDirection.Out);

            Assert.AreEqual(1, outEdges.Count);

            var returnedEdge1 = outEdges.Where(x => x.String("_id") == edge1.String("_id")).First();

            Assert.AreEqual(false, edge1.IsNull("_id"));
            Assert.AreEqual(false, edge1.IsNull("_key"));
            Assert.AreEqual(false, edge1.IsNull("_rev"));
            Assert.AreEqual(false, edge1.IsNull("_from"));
            Assert.AreEqual(false, edge1.IsNull("_to"));
            Assert.AreEqual(false, edge1.IsNull("edgeFoo"));
            Assert.AreEqual(false, edge1.IsNull("edgeBar"));
            Assert.AreEqual(false, returnedEdge1.IsNull("_id"));
            Assert.AreEqual(false, returnedEdge1.IsNull("_key"));
            Assert.AreEqual(false, returnedEdge1.IsNull("_rev"));
            Assert.AreEqual(false, returnedEdge1.IsNull("_from"));
            Assert.AreEqual(false, returnedEdge1.IsNull("_to"));
            Assert.AreEqual(false, returnedEdge1.IsNull("edgeFoo"));
            Assert.AreEqual(false, returnedEdge1.IsNull("edgeBar"));

            Assert.AreEqual(edge1.String("_id"), returnedEdge1.String("_id"));
            Assert.AreEqual(edge1.String("_key"), returnedEdge1.String("_key"));
            Assert.AreEqual(edge1.String("_rev"), returnedEdge1.String("_rev"));
            Assert.AreEqual(edge1.String("_from"), returnedEdge1.String("_from"));
            Assert.AreEqual(edge1.String("_to"), returnedEdge1.String("_to"));
            Assert.AreEqual(edge1.Has("edgeFoo"), returnedEdge1.Has("edgeFoo"));
            Assert.AreEqual(edge1.String("edgeFoo"), returnedEdge1.String("edgeFoo"));
            Assert.AreEqual(edge1.Has("edgeBar"), returnedEdge1.Has("edgeBar"));
            Assert.AreEqual(edge1.Int("edgeBar"), returnedEdge1.Int("edgeBar"));
        }
开发者ID:jsteemann,项目名称:ArangoDB-NET,代码行数:70,代码来源:ArangoEdgeTests.cs


注:本文中的Document.Has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。