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


C# MongoCollection.AsQueryable方法代码示例

本文整理汇总了C#中MongoCollection.AsQueryable方法的典型用法代码示例。如果您正苦于以下问题:C# MongoCollection.AsQueryable方法的具体用法?C# MongoCollection.AsQueryable怎么用?C# MongoCollection.AsQueryable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoCollection的用法示例。


在下文中一共展示了MongoCollection.AsQueryable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindTranslation

        public static void FindTranslation(MongoCollection<Word> collection, string word)
        {
            bool containsWord = collection.AsQueryable<Word>().Any(w => w.WordText == word);
            if (!containsWord)
            {
                Console.WriteLine("Word does not exist in the dictionary.");
                return;
            }

            Word wordData = collection.AsQueryable<Word>().First(w => w.WordText == word);
            Console.WriteLine(wordData);
        }
开发者ID:PetarPenev,项目名称:Telerik,代码行数:12,代码来源:Program.cs

示例2: ListAll

 public static void ListAll(MongoCollection<Word> collection)
 {
     foreach (var word in collection.AsQueryable<Word>())
     {
         Console.WriteLine(word);
     }
 }
开发者ID:PetarPenev,项目名称:Telerik,代码行数:7,代码来源:Program.cs

示例3: WriteToSqlLite

        public static void WriteToSqlLite(MongoCollection reports)
        {
            string conString = @"Data Source=../../../supermarket.db;Version=3;";
            var dbSqLiteConnection = new SQLiteConnection(conString);
            try
            {
                dbSqLiteConnection.Open();
                var query = (from report in reports.AsQueryable<TotalReport>()
                             select report);

                foreach (var report in query)
                {
                    report.product_name = report.product_name.Replace("\"", "\"\"");
                    string commandText = String.Format(@"INSERT INTO TotalReports VALUES({0},""{1}"",""{2}"",{3}, {4});",
                        report.product_id, report.product_name, report.vendor_name, report.total_quantity_sold, report.total_incomes);

                    SQLiteCommand cmd = new SQLiteCommand(commandText, dbSqLiteConnection);
                    cmd.ExecuteNonQuery();
                }
            }
            catch (SQLiteException ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                dbSqLiteConnection.Close();
            }
        }
开发者ID:hristo11111,项目名称:Supermarket-Project,代码行数:29,代码来源:ExportReportInMongoDB.cs

示例4: PrintAllWords

        private static void PrintAllWords(MongoCollection<Word> collection)
        {
            var words = collection.AsQueryable().ToList();

            Console.WriteLine("All words in dictionary:");
            foreach (var word in words)
            {
                Console.WriteLine(word);
            }
        }
开发者ID:psotirov,项目名称:TelerikAcademyProjects,代码行数:10,代码来源:MongoDictionary.cs

示例5: AddWord

        public static void AddWord(MongoCollection<Word> collection, string word, string translation)
        {
            Word wordData = new Word(word, translation);
            bool containsWord = collection.AsQueryable<Word>().Any(w => w.WordText == word);
            if (containsWord)
            {
                Console.WriteLine("The word is already added to the dictionary.");
                return;
            }

            collection.Insert(wordData);
            Console.WriteLine("Word added");
        }
开发者ID:PetarPenev,项目名称:Telerik,代码行数:13,代码来源:Program.cs

示例6: SreachWord

 public static void SreachWord(MongoCollection words)
 {
     Console.Write("Enter word for translation: ");
     string searchedWord = Console.ReadLine().ToLower();
     var searched = words.AsQueryable<Word>().FirstOrDefault(w => w.Value == searchedWord);
     if (searched != null)
     {
         Console.WriteLine("Word: {0}\nTranslation: {1}", searched.Value, searched.Translation);
     }
     else
     {
         Console.WriteLine("This word is not exist");
     }
 }
开发者ID:Gerya,项目名称:TelerikAcademy,代码行数:14,代码来源:Utilities.cs

示例7: TaskQueue

        // http://www.yoda.arachsys.com/csharp/singleton.html 线程安全的模式
        // 静态构造函数用于初始化任何静态数据,或用于执行仅需执行一次的特定操作。在创建第一个实例或引用任何静态成员之前将调用静态构造函数。
        static TaskQueue()
        {
            tasks = new List<SpiderTask>();
            agents = new List<Agent>();
            siteCollection = (DependencyResolver.Current.GetService(typeof(IMongoRepo<Site>)) as IMongoRepo<Site>).Collection;
            taskModelCollection = (DependencyResolver.Current.GetService(typeof(IMongoRepo<TaskModel>)) as IMongoRepo<TaskModel>).Collection;

            //注意必须使用ToList避免懒惰加载,否则在每次调用taskModels对象时会再次查询,从而清空已被赋值过的Timer属性。
            //这里应该是mongo driver或mongo Respository的特殊模式。
            taskModels = taskModelCollection.AsQueryable<TaskModel>().Where(d => d.Act == (int)eAct.Normal && d.Interval > 0).ToList();
            sites = siteCollection.Find(Query<Site>.EQ(d => d.Act, (int)eAct.Normal)).ToList();
            Instance = new TaskQueue();
            Instance.ModelTimerBuild();
            Instance.Maintenance();
        }
开发者ID:zicjin,项目名称:SpiderMan,代码行数:17,代码来源:TaskQueue.cs

示例8: RemoveWords

 public static void RemoveWords(MongoCollection words)
 {
     Console.Write("Enter word for remove: ");
     string editWord = Console.ReadLine().ToLower();
     var searched = words.AsQueryable<Word>().FirstOrDefault(w => w.Value == editWord);
     if (searched != null)
     {
         var query = Query.EQ("_id", searched.Id);
         words.Remove(query);
     }
     else
     {
         Console.WriteLine("This word is not exist");
     }
 }
开发者ID:Gerya,项目名称:TelerikAcademy,代码行数:15,代码来源:Utilities.cs

示例9: Read

    private static void Read(MongoCollection<Log> logs)
    {
        Console.WriteLine("READ");

        //// Native
        //var findLogsQuery = Query.And(Query.EQ("LogType.Type", "bug"), Query.GT("LogDate", DateTime.Now.AddDays(-7)));
        //logs.Find(findLogsQuery).Print();

        //// Linq
        //var findBugsQuery = Query<Log>.Where(log => log.LogType.Type == "bug" && log.LogDate > DateTime.Now.AddDays(-7));
        //logs.Find(findBugsQuery).Print();

        // LinqToMongoDB
        var newBugs = logs.AsQueryable<Log>().Where(log => log.LogType.Type == "bug" && log.LogDate > DateTime.Now.AddDays(-7));
        newBugs.Print();
    }
开发者ID:MarKamenov,项目名称:TelerikAcademy,代码行数:16,代码来源:MongoCRUD.cs

示例10: EditWord

 public static void EditWord(MongoCollection words)
 {
     Console.Write("Enter word for edit: ");
     string editWord = Console.ReadLine().ToLower();
     Console.Write("Enter new translation: ");
     string translation = Console.ReadLine().ToLower();
     var searched = words.AsQueryable<Word>().FirstOrDefault(w => w.Value == editWord);
     if (searched != null)
     {
         var update = Update.Set("Translation", translation);
         var query = Query.EQ("_id", searched.Id);
         words.Update(query, update);
     }
     else
     {
         Console.WriteLine("This word is not exist");
     }
 }
开发者ID:Gerya,项目名称:TelerikAcademy,代码行数:18,代码来源:Utilities.cs

示例11: AddWord

        public static void AddWord(MongoCollection words)
        {
            Console.Write("Enter word: ");
            string loweredWordt = Console.ReadLine().ToLower();
            Console.Write("Enter translation: ");
            string loweredTranslation = Console.ReadLine().ToLower();
            Word newWord = new Word(loweredWordt, loweredTranslation);

            int countWords = words.AsQueryable<Word>().Where(w => w.Value == newWord.Value).Count();
            if (countWords > 0)
            {
                Console.WriteLine("This word already exist");
            }
            else
            {
                words.Insert<Word>(newWord);
            }
        }
开发者ID:Gerya,项目名称:TelerikAcademy,代码行数:18,代码来源:Utilities.cs

示例12: FindWords

        private static void FindWords(MongoCollection<Word> words)
        {
            Console.Write("Enter word to search for:");
            var word = Console.ReadLine();

            string foundWordTranslation = words.AsQueryable<Word>().
                                                Where(w => w.TheWord == word).
                                                Select(w => w.Translation).
                                                FirstOrDefault();

            if (foundWordTranslation != null)
            {
                Console.WriteLine(foundWordTranslation);
            }
            else
            {
                Console.WriteLine("No such word found!");
            }
        }
开发者ID:hristo-iliev,项目名称:TelerikHW,代码行数:19,代码来源:MongoDictionary.cs

示例13: Insert

        public static void Insert(MongoCollection<Currency> collection, Currency currency)
        {
            try
            {
                collection.CreateIndex(IndexKeys<Currency>.Descending(c => c.Date));

                var result =
                    (from c in collection.AsQueryable<Currency>()
                     where c.Date == currency.Date
                     select c)
                    .Count();

                if (result == 0)
                    collection.Insert(currency);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
开发者ID:jongh0,项目名称:MTree,代码行数:20,代码来源:Program.cs

示例14:

 private static IEnumerable<Tweet> FälligeTweets(DateTime fälligkeit, MongoCollection<Tweet> collection) {
     return collection.AsQueryable().Where(x => x.Veröffentlichen <= fälligkeit).ToList();
 }
开发者ID:slieser,项目名称:sandbox,代码行数:3,代码来源:TweetStore.cs

示例15: FindWord

 private static void FindWord(MongoCollection<Word> collection, string key)
 {
     var word = collection.AsQueryable().Where(w => w.KeyWord == key).FirstOrDefault();
     Console.WriteLine(word);
 }
开发者ID:psotirov,项目名称:TelerikAcademyProjects,代码行数:5,代码来源:MongoDictionary.cs


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