本文整理汇总了C#中MongoDB.Driver.MongoCollectionSettings类的典型用法代码示例。如果您正苦于以下问题:C# MongoCollectionSettings类的具体用法?C# MongoCollectionSettings怎么用?C# MongoCollectionSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MongoCollectionSettings类属于MongoDB.Driver命名空间,在下文中一共展示了MongoCollectionSettings类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TestClone
public void TestClone()
{
// set everything to non default values to test that all settings are cloned
var settings = new MongoCollectionSettings<BsonDocument>(_database, "collection")
{
AssignIdOnInsert = !MongoDefaults.AssignIdOnInsert,
GuidRepresentation = GuidRepresentation.PythonLegacy,
ReadPreference = ReadPreference.Secondary,
WriteConcern = WriteConcern.W2
};
var clone = settings.Clone();
Assert.IsTrue(clone.Equals(settings));
}
开发者ID:gael-ltd,项目名称:mongo-csharp-driver,代码行数:13,代码来源:MongoCollectionSettingsTests.cs
示例17: TestAssignIdOnInsert
public void TestAssignIdOnInsert()
{
var settings = new MongoCollectionSettings<BsonDocument>(_database, "collection");
Assert.AreEqual(MongoDefaults.AssignIdOnInsert, 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:gael-ltd,项目名称:mongo-csharp-driver,代码行数:13,代码来源:MongoCollectionSettingsTests.cs
示例18: TestBasic
public void TestBasic()
{
var server = MongoServer.Create();
var database = server["test"];
var it = new MongoCollectionSettings<Document>(database, "Document");
var items = from item in database.GetCollection(it)
where item.ID == 1
select item;
var count = Enumerable.Count(items);
Assert.AreEqual(1, count);
}
开发者ID:vshlos,项目名称:mongo-csharp-driver,代码行数:15,代码来源:MongoCollectionLinqTests.cs
示例19: TestAll
public void TestAll()
{
var settings = new MongoCollectionSettings
{
AssignIdOnInsert = true,
GuidRepresentation = GuidRepresentation.PythonLegacy,
ReadPreference = ReadPreference.Primary,
WriteConcern = WriteConcern.Acknowledged
};
Assert.AreEqual(true, settings.AssignIdOnInsert);
Assert.AreEqual(GuidRepresentation.PythonLegacy, settings.GuidRepresentation);
Assert.AreSame(ReadPreference.Primary, settings.ReadPreference);
Assert.AreSame(WriteConcern.Acknowledged, settings.WriteConcern);
}
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:15,代码来源:MongoCollectionSettingsTests.cs
示例20: TestAll
public void TestAll()
{
var settings = new MongoCollectionSettings<BsonDocument>(_database, "collection")
{
AssignIdOnInsert = true,
GuidRepresentation = GuidRepresentation.PythonLegacy,
ReadPreference = ReadPreference.Primary,
WriteConcern = WriteConcern.Acknowledged
};
Assert.AreEqual("collection", settings.CollectionName);
Assert.AreEqual(typeof(BsonDocument), settings.DefaultDocumentType);
Assert.AreEqual(true, settings.AssignIdOnInsert);
Assert.AreEqual(GuidRepresentation.PythonLegacy, settings.GuidRepresentation);
Assert.AreSame(ReadPreference.Primary, settings.ReadPreference);
Assert.AreSame(WriteConcern.Acknowledged, settings.WriteConcern);
}
开发者ID:gael-ltd,项目名称:mongo-csharp-driver,代码行数:17,代码来源:MongoCollectionSettingsTests.cs
注:本文中的MongoDB.Driver.MongoCollectionSettings类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论