本文整理汇总了C#中MongoCollection.FindAll方法的典型用法代码示例。如果您正苦于以下问题:C# MongoCollection.FindAll方法的具体用法?C# MongoCollection.FindAll怎么用?C# MongoCollection.FindAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoCollection
的用法示例。
在下文中一共展示了MongoCollection.FindAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReloadExisting
public void ReloadExisting()
{
connectionString = "mongodb://localhost/?safe=true";
server = MongoServer.Create(connectionString);
habraDb = server.GetDatabase("habr", SafeMode.True);
posts = habraDb.GetCollection<Post>("posts");
existedBeforeCount = posts.Count();
using (client = new WebClient())
{
client.Encoding = Encoding.UTF8;
foreach (var post in posts.FindAll())
{
try
{
Console.Clear();
Console.WriteLine(string.Format("Reloaded: {0} posts of {1} possible", reloadedCount, existedBeforeCount));
Console.WriteLine("Processing: " + post.Url);
Console.WriteLine("Loading...");
string pageContent = client.DownloadString(post.Url);
Console.WriteLine("Parsing...");
ParsePostPage(post.Url, pageContent);
}
catch { }
}
}
}
示例2: GetDocuments
protected virtual IEnumerable<BsonDocument> GetDocuments(MongoCollection<BsonDocument> collection)
{
var query = Filter();
return query != null
? collection.Find(query)
: collection.FindAll();
}
示例3: Delete
private static void Delete(MongoCollection<Log> logs)
{
var findOldLogsQuery = Query.And(Query.LT("LogDate", DateTime.Now.AddDays(-1)));
logs.Remove(findOldLogsQuery);
Console.WriteLine("DELETE");
logs.FindAll().Print();
}
示例4: Create
private static void Create(MongoCollection<Log> logs)
{
logs.InsertBatch(CreateSampleLogs(10));
logs.Insert(new Log("Some logs added", DateTime.Now));
Console.WriteLine("CREATE");
logs.FindAll().Print();
}
示例5: Init
public void Init(MongoCollection<StockData> coll)
{
StockIdAndDates_.Clear();
foreach (var item in coll.FindAll())
{
AddStockDay(item.StockId, item.TradeDate);
}
}
示例6: ListDictonary
public static void ListDictonary(MongoCollection<BsonDocument> dictonary)
{
Console.WriteLine("List");
foreach (var item in dictonary.FindAll())
{
Console.WriteLine(new string('-', Console.WindowWidth - 5));
foreach (var book in item.Values)
{
Console.WriteLine(book);
}
}
}
示例7: AddFromCollection
public static INConfigSettings AddFromCollection(this INConfigSettings settings,
MongoCollection<Section> collection)
{
if (!BsonClassMap.IsClassMapRegistered(typeof(Section)))
{
// Register Section in BsonClassMap to ignore automatically-added "_id" property
BsonClassMap.RegisterClassMap<Section>(cm =>
{
cm.AutoMap();
cm.SetIgnoreExtraElements(true);
});
}
var provider = new ConvertFromSectionDataProvider(() => collection.FindAll().ToList(), settings);
return settings.AddConfigurationDataProvider(provider);
}
示例8: ExportCollectionToJson
private static void ExportCollectionToJson(MongoCollection<BsonDocument> productsReports)
{
string jsonReportsDirectory = @"..\..\..\JsonReports\";
if (Directory.Exists(jsonReportsDirectory))
{
Directory.Delete(jsonReportsDirectory, true);
}
Directory.CreateDirectory(jsonReportsDirectory);
var reports = productsReports.FindAll();
foreach (var report in reports)
{
CreateJsonFile(jsonReportsDirectory, report);
}
}
示例9: Start
protected void Start()
{
client = new MongoClient(new MongoUrl("mongodb://Unity:[email protected]:49624/wordriver"));
server = client.GetServer();
server.Connect();
db = server.GetDatabase("wordriver");
allContextPacks = db.GetCollection<BsonDocument>("contextpacks");
allWords = db.GetCollection<BsonDocument>("words");
allWordPacks = db.GetCollection<BsonDocument>("wordpacks");
foreach (BsonDocument item in allWords.FindAll())
{
BsonElement name = item.GetElement("name");
string wordValue = name.Value.ToString();
alltiles.Add(wordValue);
}
Readable.Speak("Welcome to Story Builder!");
}
示例10: Form1
public Form1()
{
InitializeComponent();
var connectionString = "mongodb://localhost/?safe=true";
var server = MongoServer.Create(connectionString);
var database = server.GetDatabase("Zalagaonica");
collectionUgovor = database.GetCollection<UgovorClass>("ugovor");
collectionIspostava = database.GetCollection<RadnjaClass>("radnja");
collectionZalagac = database.GetCollection<ZalagacClass>("zalagac");
ispostave = new List<MongoDBRef>();
Zalagaci = new List<MongoDBRef>();
foreach (var item in collectionIspostava.FindAll())
{
ispostave.Add(new MongoDBRef("radnja", item.Id));
comboBox1.Items.Add("ispodtava broj: " + item.broj + " - " + item.adresa);
}
foreach (var item in collectionZalagac.FindAll())
{
Zalagaci.Add(new MongoDBRef("zalagac", item.id));
comboBox2.Items.Add(item.ime + item.prezime);
}
}
示例11: CreateCursor
private MongoCursor<BsonDocument> CreateCursor(MongoCollection<BsonDocument> collection, SimpleExpression criteria)
{
if (criteria == null)
return collection.FindAll();
var mongoQuery = _expressionFormatter.Format(criteria);
return collection.Find(mongoQuery);
}
示例12: GetAllRecordsInCollection
private static ICollection<JobReport> GetAllRecordsInCollection(MongoCollection<BsonDocument> collection)
{
var jobs = collection.FindAll();
List<JobReport> reports = new List<JobReport>();
foreach (var job in jobs)
{
if (!job.Contains("_id") || !job.Contains("Success"))
{
throw new ArgumentException("There is an invalid row in the Mongo Database");
}
int jobId = job["_id"].AsInt32;
bool isSuccessful = job["Success"].AsBoolean;
JobReport report = new JobReport()
{
Id = jobId,
Success = isSuccessful
};
if (job.Contains("EndDate") && job["EndDate"].IsValidDateTime)
{
report.EndDate = job["EndDate"].ToUniversalTime();
}
else
{
report.EndDate = DateTime.Now;
}
if (job.Contains("KillCount"))
{
report.KillCount = job["KillCount"].AsInt32;
}
reports.Add(report);
}
return reports;
}
示例13: ShowMachineTitleField_OptimalWay
private void ShowMachineTitleField_OptimalWay(MongoCollection<BsonDocument> machineCollection)
{
Console.Write("\nОптимальный способ:\n\n");
foreach (BsonDocument item in machineCollection.FindAll().SetFields(Fields.Exclude("_id").Include(MACHINE_ITEM_NAME)))
{
Console.WriteLine(item[MACHINE_ITEM_NAME]);
}
}
示例14: ShowMachineTitleField_NonoptimalWay
private void ShowMachineTitleField_NonoptimalWay(MongoCollection<BsonDocument> machineCollection)
{
Console.WriteLine("\nНе оптимальный способ:\n\n");
foreach (BsonDocument item in machineCollection.FindAll())
{
Console.WriteLine(item[MACHINE_ITEM_NAME]);
}
}
示例15: PrintAllEntries
static void PrintAllEntries(MongoCollection<DictionaryEntry> dictionary)
{
foreach (var entry in dictionary.FindAll())
{
Console.WriteLine(entry);
}
}