本文整理汇总了C#中MongoCollection.RemoveAll方法的典型用法代码示例。如果您正苦于以下问题:C# MongoCollection.RemoveAll方法的具体用法?C# MongoCollection.RemoveAll怎么用?C# MongoCollection.RemoveAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoCollection
的用法示例。
在下文中一共展示了MongoCollection.RemoveAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MOngoTests
public MOngoTests()
{
server = MongoServer.Create();
database = server.GetDatabase("Diplome");
collection = database.GetCollection<Test>("companies");
collection.RemoveAll();
}
示例2: ContactRepository
public ContactRepository(string connection)
{
if (string.IsNullOrWhiteSpace(connection))
{
connection = "mongodb://localhost:27017";
}
_client = new MongoClient(connection);
_server = _client.GetServer();
_database = _server.GetDatabase("Contacts", WriteConcern.Unacknowledged);
_contacts = _database.GetCollection<Contact>("contacts");
// Reset database and add some default entries
_contacts.RemoveAll();
for (int index = 1; index < 5; index++)
{
Contact contact1 = new Contact
{
Email = string.Format("test{0}@example.com", index),
Name = string.Format("test{0}", index),
Phone = string.Format("{0}{0}{0} {0}{0}{0} {0}{0}{0}{0}", index)
};
AddContact(contact1);
}
}
示例3: TodoRepository
public TodoRepository(string connection)
{
if (string.IsNullOrWhiteSpace(connection))
{
connection = ConfigurationManager.AppSettings["TodoConnectionString"];
}
_server = MongoServer.Create(connection);
_database = _server.GetDatabase(ConfigurationManager.AppSettings["TodoDatabaseName"], SafeMode.True);
_todos = _database.GetCollection<Todo>(ConfigurationManager.AppSettings["TodoTableName"]);
bool resetData = true;
bool.TryParse(ConfigurationManager.AppSettings["ResetData"], out resetData);
if (resetData)
{
_todos.RemoveAll();
for (int i = 0; i < 5; i++)
{
Todo todo = new Todo
{
Description = string.Format("Todo {0}", i + 1),
Done = (i % 3 == 0 ? true : false),
CreationDatetime = DateTime.Now,
DoneDatetime = null
};
if (todo.Done)
todo.DoneDatetime = DateTime.Now;
AddTodo(todo);
}
}
}
示例4: ResetDb
public void ResetDb()
{
var cli = new MongoClient(CONNECTIONSTRING);
var ser = cli.GetServer();
var db = ser.GetDatabase("Instavote");
_col = db.GetCollection("Trainings");
_col.RemoveAll();
}
示例5: SetUp
public void SetUp()
{
GlobalContext.Properties.Clear();
ThreadContext.Properties.Clear();
MongoServer conn = MongoServer.Create("mongodb://localhost");
MongoDatabase db = conn.GetDatabase("log4net");
_collection = db.GetCollection("logs");
_collection.RemoveAll();
}
示例6: ClearRecords
private static void ClearRecords(MongoCollection<BsonDocument> collection)
{
collection.RemoveAll();
}
示例7: SetUp
public void SetUp()
{
topicsCollection = mongoDb.GetCollection(MongoDbConstants.Collections.Topics);
topicsCollection.RemoveAll();
}