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


C# MongoRepository.Single方法代码示例

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


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

示例1: Update

        public ActionResult Update(DeployDataFromView model)
        {
            var deploy = new DeploymentJob();
            deploy.Id = Guid.NewGuid().ToString();
            deploy.Date = DateTime.Now;

            var Companies = new MongoRepository<Company>();
            deploy.Company = Companies.Single(c => c.CompanyKey == model.deployData["Company"]);
            var Environments = new MongoRepository<Entities.Environment>();
            deploy.Server = Environments.Single(e=>e.Id==model.deployData["Environment"]);
            var Revisions = new MongoRepository<Revision>();
            deploy.Revision = Revisions.Single(r=>r.Id== model.deployData["Revision"]);
            if (model.deployData["DeploySide"] == "Server")
            {
                if (model.deployData.ContainsKey("Database") && model.deployData["Database"]=="True")
                {
                    deploy.Database = true;
                }
                if (model.deployData.ContainsKey("Create") && model.deployData["Create"] == "True")
                {
                    deploy.Create = true;
                }
            }
            else
            {
                deploy.ServerSide = false;
                deploy.ClientSide = true;
                if (model.deployData.ContainsKey("Android") && model.deployData["Android"] == "True")
                {
                    deploy.Android = true;
                }
                if (model.deployData.ContainsKey("Callbox") && model.deployData["Callbox"] == "True")
                {
                    deploy.CallBox = true;
                }
                if (model.deployData.ContainsKey("IosAdhoc") && model.deployData["IosAdhoc"] == "True")
                {
                    deploy.IosAdhoc = true;
                }
                if (model.deployData.ContainsKey("IosAppStore") && model.deployData["IosAppStore"] == "True")
                {
                    deploy.IosAppStore = true;
                }
            }

            Repository.Add(deploy);
            return View();
        }
开发者ID:EugeneDP,项目名称:Code-Sample,代码行数:48,代码来源:DeploymentController.cs

示例2: OverrideCollectionName

        public void OverrideCollectionName()
        {
            IRepository<Customer> _customerRepo = new MongoRepository<Customer>("mongodb://localhost/MongoRepositoryTests", "TestCustomers123");
            _customerRepo.Add(new Customer() { FirstName = "Test" });
            Assert.IsTrue(_customerRepo.Single().FirstName.Equals("Test"));
            Assert.AreEqual("TestCustomers123", _customerRepo.Collection.Name);
            Assert.AreEqual("TestCustomers123", ((MongoRepository<Customer>)_customerRepo).CollectionName);

            IRepositoryManager<Customer> _curstomerRepoManager = new MongoRepositoryManager<Customer>("mongodb://localhost/MongoRepositoryTests", "TestCustomers123");
            Assert.AreEqual("TestCustomers123", _curstomerRepoManager.Name);
        }
开发者ID:rodolfofadino,项目名称:MongoRepository-Fork,代码行数:11,代码来源:RepoTests.cs

示例3: RepositoryUpdateTest

        public void RepositoryUpdateTest()
        {
            var target = new MongoContext();
            var repository = new MongoRepository<Employee>(target);
            var expected = "Albert2";
            Employee employee = null;
            Yekzen.QualityTools.UnitTest.ExceptionAssert.InconclusiveWhenThrows<UnreachableException>(() => { employee = InsertInternal(repository); });

            employee.FirstName = expected;

            repository.Update(p => p.Id == employee.Id,employee);

            Yekzen.QualityTools.UnitTest.ExceptionAssert.InconclusiveWhenThrows<UnreachableException>(() => { employee = repository.Single(p => p.Id == employee.Id); });

            var actual = employee.FirstName;

            Assert.AreEqual(expected, actual);
        }
开发者ID:baozkan,项目名称:Tiktak,代码行数:18,代码来源:MongoContextTest.cs

示例4: RepositoryDeleteTest

        public void RepositoryDeleteTest()
        {
            var target = new MongoContext();
            var repository = new MongoRepository<Employee>(target);
            Employee employee = null;

            Yekzen.QualityTools.UnitTest.ExceptionAssert.InconclusiveWhenThrows<UnreachableException>(() => { employee = InsertInternal(repository); });

            if(string.IsNullOrEmpty(employee.Id))
                Assert.Inconclusive("Insert failed.");

            repository.Delete(p => p.Id == employee.Id);

            employee = repository.Single(p => p.Id == employee.Id);

            Assert.IsNull(employee);
        }
开发者ID:baozkan,项目名称:Tiktak,代码行数:17,代码来源:MongoContextTest.cs


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