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


C# Document.ToString方法代码示例

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


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

示例1: TestBuilderSetsAllProperties

        public void TestBuilderSetsAllProperties()
        {
            Document query = new Document().Append("x",1);
            Document scope = new Document().Append("y",2);
            Document sort = new Document().Append("z",3);
            MapReduceBuilder mrb = mrcol.MapReduceBuilder();
            mrb.Map(mapfunction)
                    .Reduce(reducefunction)
                    .KeepTemp(true)
                    .Limit(5)
                    .Out("outtest")
                    .Query(query)
                    .Scope(scope)
                    .Sort(sort)
                    .Verbose(false);

            MapReduce mr = mrb.MapReduce;
            Assert.AreEqual(query.ToString(), mr.Query.ToString());
            Assert.AreEqual(scope.ToString(), mr.Scope.ToString());
            Assert.AreEqual(sort.ToString(), mr.Sort.ToString());
            Assert.AreEqual(true, mr.KeepTemp);
            Assert.AreEqual(5, mr.Limit);
            Assert.AreEqual("outtest", mr.Out);
            Assert.AreEqual(false, mr.Verbose);
        }
开发者ID:kvnsmth,项目名称:mongodb-csharp,代码行数:25,代码来源:TestMapReduceBuilder.cs

示例2: TestRoundTrip

        public void TestRoundTrip()
        {
            Document idoc = new Document();
            idoc.Add("b",new Binary(new byte[]{(byte)1,(byte)2}));

            MemoryStream stream = new MemoryStream();
            BsonWriter writer = new BsonWriter(stream);
            writer.Write(idoc);

            stream.Seek(0,SeekOrigin.Begin);
            BsonReader reader = new BsonReader(stream);
            Document odoc = reader.Read();

            Assert.AreEqual(idoc.ToString(), odoc.ToString());
        }
开发者ID:sdether,项目名称:mongodb-csharp,代码行数:15,代码来源:TestBsonBinary.cs

示例3: TestRoundTrip

        public void TestRoundTrip()
        {
            Document idoc = new Document();
            idoc.Add("b",new Binary(new byte[]{(byte)1,(byte)2}));
            BsonDocument bidoc = BsonConvert.From(idoc);

            MemoryStream stream = new MemoryStream();
            BsonWriter writer = new BsonWriter(stream);
            bidoc.Write(writer);

            stream.Seek(0,SeekOrigin.Begin);
            BsonReader reader = new BsonReader(stream);
            BsonDocument bodoc = new BsonDocument();
            bodoc.Read(reader);
            Document odoc = (Document) bodoc.ToNative();

            Assert.AreEqual(idoc.ToString(), odoc.ToString());
        }
开发者ID:qjlee,项目名称:mongodb-csharp,代码行数:18,代码来源:TestBsonBinary.cs

示例4: TestInsertOfArray

        public void TestInsertOfArray()
        {
            OidGenerator ogen = new OidGenerator();
            IMongoCollection inserts = DB["inserts"];
            Document album = new Document();
            album["_id"] = ogen.Generate();
            album["artist"] = "Popa Chubby";
            album["title"] = "Deliveries After Dark";
            album["songs"] = new[] {
                new Document().Append("title", "Let The Music Set You Free").Append("length", "5:15").Append("_id", ogen.Generate()),
                new Document().Append("title", "Sally Likes to Run").Append("length", "4:06").Append("_id", ogen.Generate()),
                new Document().Append("title", "Deliveries After Dark").Append("length", "4:17").Append("_id", ogen.Generate()),
                new Document().Append("title", "Theme From The Godfather").Append("length", "3:06").Append("_id", ogen.Generate()),
                new Document().Append("title", "Grown Man Crying Blues").Append("length", "8:09").Append("_id", ogen.Generate()),
            };
            inserts.Insert(album);

            Document result = inserts.FindOne(new Document().Append("songs.title","Deliveries After Dark"));
            Assert.IsNotNull(result);

            Assert.AreEqual(album.ToString(), result.ToString());
        }
开发者ID:kvnsmth,项目名称:mongodb-csharp,代码行数:22,代码来源:TestCollection.cs

示例5: TestToStringForDocWithArrayOfDocs

 public void TestToStringForDocWithArrayOfDocs()
 {
     var doc = new Document().Append("foo", new[] {
         new Document().Append("a", 1),
         new Document().Append("b", 2),
         new Document().Append("c", 3),
     });
     Assert.AreEqual(@"{ ""foo"": [ { ""a"": 1 }, { ""b"": 2 }, { ""c"": 3 } ] }", doc.ToString());
 }
开发者ID:jesseemerick,项目名称:mongodb-csharp,代码行数:9,代码来源:TestDocument.cs

示例6: TestToStringForDocWithSubDocField

 public void TestToStringForDocWithSubDocField()
 {
     var doc = new Document().Append("foo", "bar").Append("baz", new Document().Append("a", 1));
     Assert.AreEqual(@"{ ""foo"": ""bar"", ""baz"": { ""a"": 1 } }", doc.ToString());
 }
开发者ID:jesseemerick,项目名称:mongodb-csharp,代码行数:5,代码来源:TestDocument.cs

示例7: TestToStringForDocWithSingleTrueField

 public void TestToStringForDocWithSingleTrueField()
 {
     var doc = new Document().Append("foo", true);
     Assert.AreEqual(@"{ ""foo"": true }", doc.ToString());
 }
开发者ID:jesseemerick,项目名称:mongodb-csharp,代码行数:5,代码来源:TestDocument.cs

示例8: TestToStringForDocWithSingleStringField

 public void TestToStringForDocWithSingleStringField()
 {
     var doc = new Document().Append("foo", "bar");
     Assert.AreEqual(@"{ ""foo"": ""bar"" }", doc.ToString());
 }
开发者ID:jesseemerick,项目名称:mongodb-csharp,代码行数:5,代码来源:TestDocument.cs

示例9: TestToStringForDocWithSingleOidField

 public void TestToStringForDocWithSingleOidField()
 {
     var doc = new Document().Append("foo", new Oid("4ac7ee91f693066f1c96b649"));
     Assert.AreEqual(@"{ ""foo"": ObjectId(""4ac7ee91f693066f1c96b649"") }", doc.ToString());
 }
开发者ID:jesseemerick,项目名称:mongodb-csharp,代码行数:5,代码来源:TestDocument.cs

示例10: TestToStringForDocWithSingleNullField

 public void TestToStringForDocWithSingleNullField()
 {
     var doc = new Document().Append("foo", null);
     Assert.AreEqual(@"{ ""foo"": null }", doc.ToString());
 }
开发者ID:jesseemerick,项目名称:mongodb-csharp,代码行数:5,代码来源:TestDocument.cs

示例11: TestToStringForDocWithSingleIntField

 public void TestToStringForDocWithSingleIntField()
 {
     var doc = new Document().Append("foo", 10);
     Assert.AreEqual(@"{ ""foo"": 10 }", doc.ToString());
 }
开发者ID:jesseemerick,项目名称:mongodb-csharp,代码行数:5,代码来源:TestDocument.cs

示例12: TestToStringForDocWithSingleDateTimeField

 public void TestToStringForDocWithSingleDateTimeField()
 {
     var doc = new Document().Append("foo", DateTime.Parse("2009-10-10T07:00:00.0000000Z"));
     Assert.AreEqual(@"{ ""foo"": ""2009-10-10T07:00:00.0000000Z"" }", doc.ToString());
 }
开发者ID:jesseemerick,项目名称:mongodb-csharp,代码行数:5,代码来源:TestDocument.cs

示例13: TestToStringForDocWithMultipleFields

 public void TestToStringForDocWithMultipleFields()
 {
     var doc = new Document().Append("foo", "bar").Append("baz", 42);
     Assert.AreEqual(@"{ ""foo"": ""bar"", ""baz"": 42 }", doc.ToString());
 }
开发者ID:jesseemerick,项目名称:mongodb-csharp,代码行数:5,代码来源:TestDocument.cs

示例14: TestToStringForDocWithArrayOfInts

 public void TestToStringForDocWithArrayOfInts()
 {
     var doc = new Document().Append("foo", new[] {1,2,3,4});
     Assert.AreEqual(@"{ ""foo"": [ 1, 2, 3, 4 ] }", doc.ToString());
 }
开发者ID:jesseemerick,项目名称:mongodb-csharp,代码行数:5,代码来源:TestDocument.cs


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