本文整理汇总了C#中RepositoryFactory.All方法的典型用法代码示例。如果您正苦于以下问题:C# RepositoryFactory.All方法的具体用法?C# RepositoryFactory.All怎么用?C# RepositoryFactory.All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RepositoryFactory
的用法示例。
在下文中一共展示了RepositoryFactory.All方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_Get_Customers_From_Database
public void Can_Get_Customers_From_Database()
{
using (var repo = new RepositoryFactory().Create())
{
var customers = repo.All<Customer>().ToList();
CollectionAssert.IsNotEmpty(customers);
}
}
示例2: AddTest
public void AddTest()
{
var clientRepo = new RepositoryFactory<IClientRepository>().ResolveRepository();
var count = clientRepo.All().Count();
clientRepo.Add(new Client{Name="UNITTEST",Description = "UNITTEST"});
clientRepo.UnitOfWork.Commit();
Assert.IsTrue(count + 1 == new RepositoryFactory<IClientRepository>().ResolveRepository().All().Count());
}
示例3: Can_Save_New_Customer_With_Orders_And_Details
public void Can_Save_New_Customer_With_Orders_And_Details()
{
var customer = GetCustomer();
using (var repo = new RepositoryFactory().Create())
{
repo.Add(customer);
repo.Save();
}
using (var repo = new RepositoryFactory().Create())
{
var cust = repo.All<Customer>().SingleOrDefault(c => c.Email == "[email protected]");
Assert.IsNotNull(cust);
CollectionAssert.IsNotEmpty(cust.Orders);
Assert.IsNotNull(cust.Orders.First(o => o.OrderDetail != null).OrderDetail);
}
}
示例4: Can_Use_UoW_To_Remove_And_Add_Customer_In_A_Transaction
public void Can_Use_UoW_To_Remove_And_Add_Customer_In_A_Transaction()
{
using (var uow = new MegaEntityFrameworkUnitOfWorkFactory().Create())
{
var repo = new RepositoryFactory().Create(uow);
var c1 = repo.All<Customer>().Single(c => c.Email == "[email protected]");
repo.Delete(c1);
var c2 = GetCustomer();
repo.Add(c2);
uow.Commit();
}
using (var repo = new RepositoryFactory().Create())
{
var x = repo.All<Customer>().SingleOrDefault(c => c.Email == "[email protected]");
Assert.IsNull(x);
var y = repo.All<Customer>().Any(c => c.Country == "Italy");
Assert.IsTrue(y);
}
}
示例5: Can_Save_New_Customer
public void Can_Save_New_Customer()
{
var customer = new Customer
{
ContactName = "johnny",
Email = "[email protected]"
};
using (var repo = new RepositoryFactory().Create())
{
repo.Add(customer);
repo.Save();
}
using (var repo = new RepositoryFactory().Create())
{
var cust = repo.All<Customer>().SingleOrDefault(c => c.Email == "[email protected]");
Assert.IsNotNull(cust);
}
}
示例6: GetAllTest
public void GetAllTest()
{
var productRepo = new RepositoryFactory<IProductRepository>().ResolveRepository();
var allProducts = productRepo.All();
Assert.IsNotNull(allProducts.FirstOrDefault());
}
示例7: GetAllTest
public void GetAllTest()
{
var clientRepo = new RepositoryFactory<IClientRepository>().ResolveRepository();
var allClients = clientRepo.All();
Assert.IsTrue(allClients.Count()>0);
}