當前位置: 首頁>>代碼示例>>C#>>正文


C# Driver.MongoCollectionSettings類代碼示例

本文整理匯總了C#中MongoDB.Driver.MongoCollectionSettings的典型用法代碼示例。如果您正苦於以下問題:C# MongoCollectionSettings類的具體用法?C# MongoCollectionSettings怎麽用?C# MongoCollectionSettings使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MongoCollectionSettings類屬於MongoDB.Driver命名空間,在下文中一共展示了MongoCollectionSettings類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestConstructorArgumentChecking

 public void TestConstructorArgumentChecking()
 {
     var settings = new MongoCollectionSettings<BsonDocument>(_database, "");
     Assert.Throws<ArgumentNullException>(() => { new MongoCollection<BsonDocument>(null, settings); });
     Assert.Throws<ArgumentNullException>(() => { new MongoCollection<BsonDocument>(_database, null); });
     Assert.Throws<ArgumentOutOfRangeException>(() => { new MongoCollection<BsonDocument>(_database, settings); });
 }
開發者ID:kayone,項目名稱:mongo-csharp-driver,代碼行數:7,代碼來源:MongoCollectionTests.cs

示例2: CSharp714Tests

 public CSharp714Tests()
 {
     _database = LegacyTestConfiguration.Database;
     var collectionSettings = new MongoCollectionSettings() { GuidRepresentation = GuidRepresentation.Standard };
     _collection = _database.GetCollection<C>("csharp714", collectionSettings);
     _collection.Drop();
 }
開發者ID:RavenZZ,項目名稱:MDRelation,代碼行數:7,代碼來源:CSharp714Tests.cs

示例3: TestEquals

        public void TestEquals()
        {
            var settings = new MongoCollectionSettings();
            var clone = settings.Clone();
            Assert.IsTrue(clone.Equals(settings));

            settings.Freeze();
            clone.Freeze();
            Assert.IsTrue(clone.Equals(settings));

            clone = settings.Clone();
            clone.AssignIdOnInsert = !clone.AssignIdOnInsert;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.GuidRepresentation = GuidRepresentation.PythonLegacy;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.ReadPreference = ReadPreference.Secondary;
            Assert.IsFalse(clone.Equals(settings));

            clone = settings.Clone();
            clone.WriteConcern = WriteConcern.W2;
            Assert.IsFalse(clone.Equals(settings));
        }
開發者ID:fir3pho3nixx,項目名稱:mongo-csharp-driver,代碼行數:26,代碼來源:MongoCollectionSettingsTests.cs

示例4: CollectionSettings

		public static MongoCollectionSettings CollectionSettings()
		{
			var collectionSettings = new MongoCollectionSettings();
			collectionSettings.WriteConcern = WriteConcern.WMajority;

			return collectionSettings;
		}
開發者ID:okusnadi,項目名稱:AspNet.Identity3.MongoDB,代碼行數:7,代碼來源:DefaultSettings.cs

示例5: TestAll

        public void TestAll()
        {
            var settings = new MongoCollectionSettings<BsonDocument>(
                "collection",
                true, // asssignIdOnInsert
                SafeMode.Create(5, TimeSpan.FromSeconds(5)),
                true // slaveOkd
            );

            Assert.AreEqual("collection", settings.CollectionName);
            Assert.AreEqual(true, settings.AssignIdOnInsert);
            Assert.AreEqual(typeof(BsonDocument), settings.DefaultDocumentType);
            Assert.AreEqual(SafeMode.Create(5, TimeSpan.FromSeconds(5)), settings.SafeMode);
            Assert.AreEqual(true, settings.SlaveOk);

            Assert.IsFalse(settings.IsFrozen);
            var hashCode = settings.GetHashCode();
            var stringRepresentation = settings.ToString();
            Assert.AreEqual(settings, settings);

            settings.Freeze();
            Assert.IsTrue(settings.IsFrozen);
            Assert.AreEqual(hashCode, settings.GetHashCode());
            Assert.AreEqual(stringRepresentation, settings.ToString());
        }
開發者ID:jenrom,項目名稱:mongo-csharp-driver,代碼行數:25,代碼來源:MongoCollectionSettingsTests.cs

示例6: TestFixtureSetup

 public void TestFixtureSetup()
 {
     _database = Configuration.TestDatabase;
     var collectionSettings = new MongoCollectionSettings() { GuidRepresentation = GuidRepresentation.Standard };
     _collection = _database.GetCollection<C>("csharp714", collectionSettings);
     _collection.Drop();
 }
開發者ID:GGsus,項目名稱:mongo-csharp-driver,代碼行數:7,代碼來源:CSharp714Tests.cs

示例7: TestAll

        public void TestAll()
        {
            var server = MongoServer.Create();
            var database = server["test"];
            var settings = new MongoCollectionSettings<BsonDocument>(database, "collection")
            {
                AssignIdOnInsert = true,
                SafeMode = SafeMode.Create(5, TimeSpan.FromSeconds(5)),
                SlaveOk = true
            };

            Assert.AreEqual("collection", settings.CollectionName);
            Assert.AreEqual(true, settings.AssignIdOnInsert);
            Assert.AreEqual(typeof(BsonDocument), settings.DefaultDocumentType);
            Assert.AreEqual(GuidRepresentation.CSharpLegacy, settings.GuidRepresentation);
            Assert.AreEqual(SafeMode.Create(5, TimeSpan.FromSeconds(5)), settings.SafeMode);
            Assert.AreEqual(true, settings.SlaveOk);

            Assert.IsFalse(settings.IsFrozen);
            var hashCode = settings.GetHashCode();
            var stringRepresentation = settings.ToString();
            Assert.AreEqual(settings, settings);

            settings.Freeze();
            Assert.IsTrue(settings.IsFrozen);
            Assert.AreEqual(hashCode, settings.GetHashCode());
            Assert.AreEqual(stringRepresentation, settings.ToString());
        }
開發者ID:FelicePollano,項目名稱:mongo-csharp-driver,代碼行數:28,代碼來源:MongoCollectionSettingsTests.cs

示例8: TestAll

        public void TestAll()
        {
            var settings = new MongoCollectionSettings();
            settings.CollectionName = "collection";
            settings.AssignIdOnInsert = false;
            settings.SafeMode = SafeMode.Create(5, TimeSpan.FromSeconds(5));
            settings.SlaveOk = true;

            Assert.AreEqual("collection", settings.CollectionName);
            Assert.AreEqual(false, settings.AssignIdOnInsert);
            Assert.AreEqual(SafeMode.Create(5, TimeSpan.FromSeconds(5)), settings.SafeMode);
            Assert.AreEqual(true, settings.SlaveOk);

            Assert.IsFalse(settings.IsFrozen);
            var hashCode = settings.GetHashCode();
            var stringRepresentation = settings.ToString();
            Assert.AreEqual(settings, settings);

            settings.Freeze();
            Assert.IsTrue(settings.IsFrozen);
            Assert.AreEqual(hashCode, settings.GetHashCode());
            Assert.AreEqual(stringRepresentation, settings.ToString());

            var clone = settings.Clone();
            Assert.IsFalse(clone.IsFrozen);
            Assert.AreEqual(settings, clone);
        }
開發者ID:modesto,項目名稱:mongo-csharp-driver,代碼行數:27,代碼來源:MongoCollectionSettingsTests.cs

示例9: MongoEventStore

        public MongoEventStore(MongoClient client)
        {
            if (client == null) throw new ArgumentNullException("client");
            this.client = client;
            BsonClassMap.RegisterClassMap<MongoEventDocument>();
            _commitSettings = new MongoCollectionSettings {AssignIdOnInsert = false, WriteConcern = WriteConcern.Acknowledged};

        }
開發者ID:jcwrequests,項目名稱:WYS.MongoDB.EventStore,代碼行數:8,代碼來源:MongoEventStore.cs

示例10: TestConstructor

 public void TestConstructor()
 {
     var settings = new MongoCollectionSettings();
     Assert.AreEqual(false, settings.AssignIdOnInsert);
     Assert.AreEqual(GuidRepresentation.Unspecified, settings.GuidRepresentation);
     Assert.AreEqual(null, settings.ReadPreference);
     Assert.AreEqual(null, settings.WriteConcern);
 }
開發者ID:fir3pho3nixx,項目名稱:mongo-csharp-driver,代碼行數:8,代碼來源:MongoCollectionSettingsTests.cs

示例11: Init

 internal static void Init(string connectionString)
 {
     var client = new MongoClient(connectionString);
     IMongoDatabase database = client.GetDatabase("sqlWithMongo");
     var collectionSettings = new MongoCollectionSettings
     {
         WriteConcern = new WriteConcern(1)
     };
     _collection = database.GetCollection<NodeLinks>("links", collectionSettings);
 }
開發者ID:bennotti,項目名稱:SqlWithMongo,代碼行數:10,代碼來源:NodeLinkRepository.cs

示例12: MongodbCollection

        public MongodbCollection(MongodbDatabase database, Type documentType, String collectionName)
        {
            if (collectionName == null) throw new ArgumentNullException("collectionName");

            _database = database;
            _documentType = documentType;
            _collectionName = collectionName;
            _metadata = _database.UniformDatabase.Metadata;

            var mongoSettings = new MongoCollectionSettings {AssignIdOnInsert = false};
            _collection = _database.Database.GetCollection(documentType, _collectionName, mongoSettings);
        }
開發者ID:sergey-korol,項目名稱:uniform,代碼行數:12,代碼來源:MongodbCollection.cs

示例13: TestFrozenCopy

 public void TestFrozenCopy()
 {
     var server = MongoServer.Create();
     var database = server["test"];
     var settings = new MongoCollectionSettings<BsonDocument>(database, "collection");
     var frozenCopy = settings.FrozenCopy();
     var secondFrozenCopy = frozenCopy.FrozenCopy();
     Assert.AreNotSame(settings, frozenCopy);
     Assert.AreSame(frozenCopy, secondFrozenCopy);
     Assert.AreEqual(false, settings.IsFrozen);
     Assert.AreEqual(true, frozenCopy.IsFrozen);
 }
開發者ID:FelicePollano,項目名稱:mongo-csharp-driver,代碼行數:12,代碼來源:MongoCollectionSettingsTests.cs

示例14: TestAssignIdOnInsert

        public void TestAssignIdOnInsert()
        {
            var settings = new MongoCollectionSettings();
            Assert.AreEqual(false, settings.AssignIdOnInsert);

            var assignIdOnInsert = !settings.AssignIdOnInsert;
            settings.AssignIdOnInsert = assignIdOnInsert;
            Assert.AreEqual(assignIdOnInsert, settings.AssignIdOnInsert);

            settings.Freeze();
            Assert.AreEqual(assignIdOnInsert, settings.AssignIdOnInsert);
            Assert.Throws<InvalidOperationException>(() => { settings.AssignIdOnInsert = assignIdOnInsert; });
        }
開發者ID:niemyjski,項目名稱:mongo-csharp-driver,代碼行數:13,代碼來源:MongoCollectionSettingsTests.cs

示例15: Setup

 public void Setup()
 {
     var settings = new MongoCollectionSettings();
     var dbSettings = new MongoDatabaseSettings();
     dbSettings.ApplyDefaultValues(new MongoServerSettings());
     settings.ApplyDefaultValues(dbSettings);
     _operationExecutor = new MockOperationExecutor();
     _subject = new MongoCollectionImpl<BsonDocument>(
         new CollectionNamespace("foo", "bar"),
         settings,
         Substitute.For<ICluster>(),
         _operationExecutor);
 }
開發者ID:rmattos,項目名稱:mongo-csharp-driver,代碼行數:13,代碼來源:MongoCollectionImplTests.cs


注:本文中的MongoDB.Driver.MongoCollectionSettings類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。