本文整理汇总了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();
}
示例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);
}
示例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);
}
示例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);
}