当前位置: 首页>>代码示例>>C#>>正文


C# MongoCollection.FindAll方法代码示例

本文整理汇总了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 { }
                }
            }
        }
开发者ID:opcheese,项目名称:DlyaCrawlerov,代码行数:28,代码来源:Crawler.cs

示例2: GetDocuments

 protected virtual IEnumerable<BsonDocument> GetDocuments(MongoCollection<BsonDocument> collection)
 {
     var query = Filter();
     return query != null
         ? collection.Find(query)
         : collection.FindAll();
 }
开发者ID:GusLab,项目名称:video-portal,代码行数:7,代码来源:CollectionMigration.cs

示例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();
 }
开发者ID:MarKamenov,项目名称:TelerikAcademy,代码行数:7,代码来源:MongoCRUD.cs

示例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();
 }
开发者ID:MarKamenov,项目名称:TelerikAcademy,代码行数:7,代码来源:MongoCRUD.cs

示例5: Init

        public void Init(MongoCollection<StockData> coll)
        {
            StockIdAndDates_.Clear();

            foreach (var item in coll.FindAll())
            {
                AddStockDay(item.StockId, item.TradeDate);
            }
        }
开发者ID:soross,项目名称:stockanalyzer,代码行数:9,代码来源:StockFindHelper.cs

示例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);
                }
            }
        }
开发者ID:HansS,项目名称:TelerikAcademy-homework,代码行数:14,代码来源:Program.cs

示例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);
        }
开发者ID:nvaron,项目名称:NConfig,代码行数:16,代码来源:NConfigSettingsExtensions.cs

示例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);
            }
        }
开发者ID:TeamMojito,项目名称:SupermarketsDatabaseClient,代码行数:16,代码来源:MongoDBConnector.cs

示例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!");
    }
开发者ID:bsimondet,项目名称:StoryBuilder,代码行数:18,代码来源:Main.cs

示例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);
            }
        }
开发者ID:ivica94,项目名称:Zalagaonica,代码行数:24,代码来源:DodavanjeArtikala.cs

示例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);
        }
开发者ID:kppullin,项目名称:Simple.Data.MongoDB,代码行数:8,代码来源:MongoAdapterFinder.cs

示例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;
        }
开发者ID:archangelmichael,项目名称:DB-TeamWork-TeamBlackDragon,代码行数:40,代码来源:MongoDBImport.cs

示例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]);
     }
 }
开发者ID:NatalyaSmertina,项目名称:MyRepository,代码行数:8,代码来源:DateBaseManager.cs

示例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]);
     }
 }
开发者ID:NatalyaSmertina,项目名称:MyRepository,代码行数:8,代码来源:DateBaseManager.cs

示例15: PrintAllEntries

 static void PrintAllEntries(MongoCollection<DictionaryEntry> dictionary)
 {
     foreach (var entry in dictionary.FindAll())
     {
         Console.WriteLine(entry);
     }       
 }
开发者ID:vladislav-karamfilov,项目名称:TelerikAcademy,代码行数:7,代码来源:DictionaryMongoDBUI.cs


注:本文中的MongoCollection.FindAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。