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


C# MongoRepository.GetAll方法代码示例

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


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

示例1: ImportMotherboards

        private void ImportMotherboards()
        {
            IRepository<Motherboard> motherboardRepository = new MongoRepository<Motherboard>(this.dbContext);
            IRepository<Vendor> vendorRepository = new MongoRepository<Vendor>(this.dbContext);

            var vendorsList = vendorRepository.GetAll().ToList();

            textWriter.Write("Importing motherboards");

            for (int i = 0; i < 45; i++)
            {
                if (i % 2 == 0)
                {
                    textWriter.Write(".");
                }

                motherboardRepository.Add(new Motherboard()
                {
                    Id = ObjectId.GenerateNewId(),
                    Model = RandomUtils.GenerateRandomString(RandomUtils.GenerateNumberInRange(2, 5)),
                    Price = RandomUtils.GenerateNumberInRange(150, 350),
                    VendorId = vendorsList[RandomUtils.GenerateNumberInRange(0, vendorsList.Count - 1)].Id
                });
            }

            textWriter.WriteLine();
        }
开发者ID:TeamBromine,项目名称:Main,代码行数:27,代码来源:MongoImporter.cs

示例2: ImportCpus

        private void ImportCpus()
        {
            int[] cpuCores = { 2, 3, 4, 6 };

            IRepository<Cpu> cpuRepository = new MongoRepository<Cpu>(this.dbContext);
            IRepository<Vendor> vendorRepository = new MongoRepository<Vendor>(this.dbContext);
            var vendorsList = vendorRepository.GetAll().ToList();

            textWriter.Write("Importing CPUs");

            for (int i = 0; i < 42; i++)
            {
                if (i % 2 == 0)
                {
                    textWriter.Write(".");
                }

                int currentCpuCoresCount = cpuCores[RandomUtils.GenerateNumberInRange(0, cpuCores.Length - 1)];
                cpuRepository.Add(new Cpu()
                {
                    Id = ObjectId.GenerateNewId(),
                    Cores = currentCpuCoresCount,
                    Model = RandomUtils.GenerateRandomString(RandomUtils.GenerateNumberInRange(2, 5)),
                    Price = currentCpuCoresCount * RandomUtils.GenerateNumberInRange(100, 120),
                    VendorId = vendorsList[RandomUtils.GenerateNumberInRange(0, vendorsList.Count - 1)].Id
                });
            }

            textWriter.WriteLine();
        }
开发者ID:TeamBromine,项目名称:Main,代码行数:30,代码来源:MongoImporter.cs

示例3: GetAll_InserTwoItem_ReturnTwo

 public void GetAll_InserTwoItem_ReturnTwo()
 {
     var repository = new MongoRepository<TestModel4>();
     repository.Drop();
     repository.Insert(new TestModel4());
     repository.Insert(new TestModel4());
     var list = repository.GetAll();
     Assert.AreEqual(2, list.Count());
 }
开发者ID:aderman,项目名称:Doco,代码行数:9,代码来源:MongoRepositoryTests.cs

示例4: ImportRams

        private void ImportRams()
        {
            int[] ramSizes = { 256, 512, 1024, 2048, 4096, 8192, 16384 };

            IRepository<Ram> ramRepository = new MongoRepository<Ram>(this.dbContext);
            IRepository<Vendor> vendorRepository = new MongoRepository<Vendor>(this.dbContext);
            var vendorsList = vendorRepository.GetAll().ToList();

            textWriter.Write("Importing RAM sticks");

            for (int i = 0; i < 30; i++)
            {
                if (i % 2 == 0)
                {
                    textWriter.Write(".");
                }

                int currentRamSize = ramSizes[RandomUtils.GenerateNumberInRange(0, ramSizes.Length - 1)];

                ramRepository.Add(new Ram()
                {
                    Id = ObjectId.GenerateNewId(),
                    Model = RandomUtils.GenerateRandomString(RandomUtils.GenerateNumberInRange(2, 6)),
                    Size = currentRamSize,
                    Price = Math.Sqrt(currentRamSize) - RandomUtils.GenerateNumberInRange(-2, 2),
                    VendorId = vendorsList[RandomUtils.GenerateNumberInRange(0, vendorsList.Count - 1)].Id
                });
            }

            textWriter.WriteLine();
        }
开发者ID:TeamBromine,项目名称:Main,代码行数:31,代码来源:MongoImporter.cs

示例5: ImportPsus

        private void ImportPsus()
        {
            int[] psuPowers = { 400, 450, 500, 600, 650, 700, 750 };

            IRepository<Psu> psuRepository = new MongoRepository<Psu>(this.dbContext);
            IRepository<Vendor> vendorRepository = new MongoRepository<Vendor>(this.dbContext);
            var vendorsList = vendorRepository.GetAll().ToList();

            textWriter.Write("Importing PSUs");

            for (int i = 0; i < 25; i++)
            {
                if (i % 2 == 0)
                {
                    textWriter.Write(".");
                }

                int currentPsuPower = psuPowers[RandomUtils.GenerateNumberInRange(0, psuPowers.Length - 1)];

                psuRepository.Add(new Psu()
                {
                    Id = ObjectId.GenerateNewId(),
                    Model = RandomUtils.GenerateRandomString(RandomUtils.GenerateNumberInRange(2, 5)),
                    Power = currentPsuPower,
                    Price = currentPsuPower / RandomUtils.GenerateNumberInRange(3, 5),
                    VendorId = vendorsList[RandomUtils.GenerateNumberInRange(0, vendorsList.Count - 1)].Id
                });
            }

            textWriter.WriteLine();
        }
开发者ID:TeamBromine,项目名称:Main,代码行数:31,代码来源:MongoImporter.cs


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