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


C# BsonDocument.ContainsValue方法代码示例

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


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

示例1: BsonDocMethod

        static async Task BsonDocMethod()
        {
            var doc = new BsonDocument
            {
                {"name", "Sanya" }

            };

            doc.Add("age", 30);

            doc["profession"] = "hacker";

            var nestedArray = new BsonArray();

            nestedArray.Add(new BsonDocument("color", "red"));

            doc.Add("array", nestedArray);

            Console.WriteLine(1);
            //Console.WriteLine(doc.TryGetElement("name", out name));

            Console.WriteLine(doc.Count());

            Console.WriteLine();

            Console.WriteLine(doc.ContainsValue("Sanya"));

            Console.WriteLine(doc.Contains("name"));

            Console.WriteLine(doc);

            //var doc2 = new BsonDocument
            //{
            //    { "Name", "Smith"},
            //    {"Something", "something else" },
            //    {"profession", "hacker" }
            //};

            //await collectionUsed.InsertManyAsync(new[] { doc, doc2 });
        }
开发者ID:mesztomi,项目名称:Mongod1,代码行数:40,代码来源:PlaceholderProbalkozasok.cs

示例2: TestCreateFromDictionary

 public void TestCreateFromDictionary()
 {
     var dictionary = new Dictionary<string, object> { { "x", 1 }, { "n", null }, { "a", new object[] { 1, null } } }; // null will be mapped to BsonNull.Value
     var document = new BsonDocument(dictionary);
     Assert.AreEqual(3, document.ElementCount);
     Assert.AreEqual(1, document["x"].AsInt32);
     Assert.AreSame(BsonNull.Value, document["n"]);
     Assert.IsTrue(document["a"].IsBsonArray);
     Assert.AreEqual(2, document["a"].AsBsonArray.Count);
     Assert.AreEqual(1, document["a"][0].AsInt32);
     Assert.AreSame(BsonNull.Value, document["a"][1]);
     Assert.AreEqual(true, document.Contains("x"));
     Assert.AreEqual(true, document.Contains("n"));
     Assert.AreEqual(true, document.Contains("a"));
     Assert.AreEqual(true, document.ContainsValue(1));
     Assert.AreEqual(true, document.ContainsValue(BsonNull.Value));
 }
开发者ID:jijamw,项目名称:mongo-csharp-driver,代码行数:17,代码来源:BsonDocumentTests.cs

示例3: TestContainsValue

 public void TestContainsValue()
 {
     var document = new BsonDocument();
     Assert.IsFalse(document.ContainsValue(1));
     document["x"] = 1;
     Assert.IsTrue(document.ContainsValue(1));
 }
开发者ID:jijamw,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BsonDocumentTests.cs

示例4: TestConstructorNoArgs

        public void TestConstructorNoArgs()
        {
            var document = new BsonDocument();
            Assert.AreEqual(false, document.AllowDuplicateNames);
            Assert.IsInstanceOf<BsonDocument>(document.AsBsonDocument);
            Assert.AreEqual(BsonType.Document, document.BsonType);
            Assert.AreEqual(false, document.Contains("name"));
            Assert.AreEqual(false, document.ContainsValue(0));
            Assert.AreEqual(0, document.ElementCount);
            Assert.AreEqual(0, document.Elements.Count());
            Assert.AreEqual(false, document.IsBsonArray);
            Assert.AreEqual(true, document.IsBsonDocument);
            Assert.AreEqual(0, document.Names.Count());
#pragma warning disable 618
            Assert.AreEqual(null, document.RawValue);
            Assert.AreEqual(0, document.RawValues.Count());
#pragma warning restore
            Assert.AreEqual(true, document.ToBoolean());
            Assert.AreSame(document, document.ToBsonDocument());
            Assert.AreEqual("{ }", document.ToJson());
            Assert.AreEqual(0, document.Values.Count());
        }
开发者ID:jijamw,项目名称:mongo-csharp-driver,代码行数:22,代码来源:BsonDocumentTests.cs

示例5: TestConstructorNameValue

 public void TestConstructorNameValue()
 {
     var document = new BsonDocument("x", 1);
     Assert.AreEqual(1, document.ElementCount);
     Assert.AreEqual(1, document["x"].AsInt32);
     Assert.AreEqual(true, document.Contains("x"));
     Assert.AreEqual(true, document.ContainsValue(1));
 }
开发者ID:jijamw,项目名称:mongo-csharp-driver,代码行数:8,代码来源:BsonDocumentTests.cs

示例6: TestConstructorIDictionaryWithKeys

        public void TestConstructorIDictionaryWithKeys()
        {
            var hashtable = (IDictionary)new Hashtable { { "x", 1 }, { "y", 2 } };
            var keys = new string[] { "x" };
#pragma warning disable 618
            var document = new BsonDocument(hashtable, keys);
#pragma warning restore
            Assert.AreEqual(1, document.ElementCount);
            Assert.AreEqual(1, document["x"].AsInt32);
            Assert.AreEqual(true, document.Contains("x"));
            Assert.AreEqual(true, document.ContainsValue(1));
        }
开发者ID:jijamw,项目名称:mongo-csharp-driver,代码行数:12,代码来源:BsonDocumentTests.cs

示例7: TestConstructorIDictionaryGenericWithKeys

        public void TestConstructorIDictionaryGenericWithKeys()
        {
            var dictionary = (IDictionary<string, object>)new Dictionary<string, object> { { "x", 1 }, { "y", 2 } };
            var keys = new string[] { "x" };
#pragma warning disable 618
            var document = new BsonDocument(dictionary, keys);
#pragma warning restore
            Assert.AreEqual(1, document.ElementCount);
            Assert.AreEqual(1, document["x"].AsInt32);
            Assert.AreEqual(true, document.Contains("x"));
            Assert.AreEqual(true, document.ContainsValue(1));
        }
开发者ID:jijamw,项目名称:mongo-csharp-driver,代码行数:12,代码来源:BsonDocumentTests.cs

示例8: TestConstructorIDictionaryGeneric

 public void TestConstructorIDictionaryGeneric()
 {
     var dictionary = (IDictionary<string, object>)new Dictionary<string, object> { { "x", 1 } };
     var document = new BsonDocument(dictionary);
     Assert.AreEqual(1, document.ElementCount);
     Assert.AreEqual(1, document["x"].AsInt32);
     Assert.AreEqual(true, document.Contains("x"));
     Assert.AreEqual(true, document.ContainsValue(1));
 }
开发者ID:jijamw,项目名称:mongo-csharp-driver,代码行数:9,代码来源:BsonDocumentTests.cs

示例9: TestConstructorIDictionary

 public void TestConstructorIDictionary()
 {
     var hashtable = (IDictionary)new Hashtable { { "x", 1 } };
     var document = new BsonDocument(hashtable);
     Assert.AreEqual(1, document.ElementCount);
     Assert.AreEqual(1, document["x"].AsInt32);
     Assert.AreEqual(true, document.Contains("x"));
     Assert.AreEqual(true, document.ContainsValue(1));
 }
开发者ID:jijamw,项目名称:mongo-csharp-driver,代码行数:9,代码来源:BsonDocumentTests.cs

示例10: TestConstructorElementsParams

        public void TestConstructorElementsParams()
        {
            var element1 = new BsonElement("x", 1);
            var element2 = new BsonElement("y", 2);
#pragma warning disable 618
            var document = new BsonDocument(element1, element2);
#pragma warning restore
            Assert.AreEqual(2, document.ElementCount);
            Assert.AreEqual(1, document["x"].AsInt32);
            Assert.AreEqual(2, document["y"].AsInt32);
            Assert.AreEqual(true, document.Contains("x"));
            Assert.AreEqual(true, document.Contains("y"));
            Assert.AreEqual(true, document.ContainsValue(1));
            Assert.AreEqual(true, document.ContainsValue(2));
            Assert.AreSame(element1, document.GetElement("x"));
            Assert.AreSame(element2, document.GetElement("y"));
        }
开发者ID:jijamw,项目名称:mongo-csharp-driver,代码行数:17,代码来源:BsonDocumentTests.cs

示例11: TestConstructorElementsDocument

 public void TestConstructorElementsDocument()
 {
     var originalDocument = new BsonDocument { { "x", 1 }, { "y", 2 } };
     var document = new BsonDocument(originalDocument);
     Assert.AreEqual(2, document.ElementCount);
     Assert.AreEqual(1, document["x"].AsInt32);
     Assert.AreEqual(2, document["y"].AsInt32);
     Assert.AreEqual(true, document.Contains("x"));
     Assert.AreEqual(true, document.Contains("y"));
     Assert.AreEqual(true, document.ContainsValue(1));
     Assert.AreEqual(true, document.ContainsValue(2));
     Assert.AreSame(originalDocument.GetElement("x"), document.GetElement("x"));
     Assert.AreSame(originalDocument.GetElement("y"), document.GetElement("y"));
 }
开发者ID:jijamw,项目名称:mongo-csharp-driver,代码行数:14,代码来源:BsonDocumentTests.cs

示例12: TestConstructorElements

 public void TestConstructorElements()
 {
     var elements = new BsonElement[] {
         new BsonElement("x", 1),
         new BsonElement("y", 2)
     };
     var document = new BsonDocument((IEnumerable<BsonElement>)elements);
     Assert.AreEqual(2, document.ElementCount);
     Assert.AreEqual(1, document["x"].AsInt32);
     Assert.AreEqual(2, document["y"].AsInt32);
     Assert.AreEqual(true, document.Contains("x"));
     Assert.AreEqual(true, document.Contains("y"));
     Assert.AreEqual(true, document.ContainsValue(1));
     Assert.AreEqual(true, document.ContainsValue(2));
     Assert.AreSame(elements[0], document.GetElement("x"));
     Assert.AreSame(elements[1], document.GetElement("y"));
 }
开发者ID:jijamw,项目名称:mongo-csharp-driver,代码行数:17,代码来源:BsonDocumentTests.cs

示例13: TestConstructorElement

 public void TestConstructorElement()
 {
     var element = new BsonElement("x", 1);
     var document = new BsonDocument(element);
     Assert.Equal(1, document.ElementCount);
     Assert.Equal(1, document["x"].AsInt32);
     Assert.Equal(true, document.Contains("x"));
     Assert.Equal(true, document.ContainsValue(1));
     Assert.Same(element.Value, document.GetElement("x").Value);
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:10,代码来源:BsonDocumentTests.cs


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