本文整理汇总了C#中MongoCollection.Exists方法的典型用法代码示例。如果您正苦于以下问题:C# MongoCollection.Exists方法的具体用法?C# MongoCollection.Exists怎么用?C# MongoCollection.Exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoCollection
的用法示例。
在下文中一共展示了MongoCollection.Exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
_collection = Configuration.GetTestCollection<BsonDocument>();
if (_collection.Exists()) { _collection.Drop(); }
_collection.Insert(new BsonDocument { { "x", 1 } });
_collection.Insert(new BsonDocument { { "x", 2 }, { "Length", BsonNull.Value } });
_collection.Insert(new BsonDocument { { "x", 3 }, { "Length", 123 } });
}
示例2: CSharp840
public CSharp840()
{
_collection = LegacyTestConfiguration.GetCollection<BsonDocument>();
if (_collection.Exists()) { _collection.Drop(); }
_collection.Insert(new BsonDocument { { "x", 1 } });
_collection.Insert(new BsonDocument { { "x", 2 }, { "Length", BsonNull.Value } });
_collection.Insert(new BsonDocument { { "x", 3 }, { "Length", 123 } });
}
示例3: Context
public void Context()
{
var connectionStringUrl = new MongoUrl("mongodb://localhost/integration_tests");
MongoDatabase mongoDatabase = MongoDatabase.Create(connectionStringUrl);
mongoCollection = mongoDatabase.GetCollection("end_to_end_tests");
if(mongoCollection.Exists())
{
mongoCollection.Drop();
}
var elementWithIEnumerableProperty = new ElementWithIEnumerableProperty{Name = "Test", Objects = new List<object>{"Test value for serialization"}.Select(x =>x)};
mongoCollection.Insert(elementWithIEnumerableProperty);
}
示例4: SetUp
public void SetUp()
{
_collection = LegacyTestConfiguration.GetCollection<C>();
if (_collection.Exists()) { _collection.Drop(); }
}
示例5: setup
public bool setup(string connectionString, string databaseString, string collectionString)
{
_client = new MongoClient(connectionString);
_server = _client.GetServer();
_database = _server.GetDatabase(databaseString);
_collection = _database.GetCollection<Entity>(collectionString);
//If Collection exists, then everything else must exist
if (_collection.Exists())
{
return true;
}
else
{
return false;
}
}
示例6: CSharp801
public CSharp801()
{
_collection = LegacyTestConfiguration.GetCollection<C>();
if (_collection.Exists()) { _collection.Drop(); }
}