本文整理汇总了C#中CustomerRepository.GetAll方法的典型用法代码示例。如果您正苦于以下问题:C# CustomerRepository.GetAll方法的具体用法?C# CustomerRepository.GetAll怎么用?C# CustomerRepository.GetAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CustomerRepository
的用法示例。
在下文中一共展示了CustomerRepository.GetAll方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllWithNullArgument_ThrowsExceptions
public void GetAllWithNullArgument_ThrowsExceptions()
{
using (CustomerRepository repository = new CustomerRepository())
{
IEnumerable<Customer> customers =
repository.GetAll(null);
Assert.Fail("Show have thrown an ArgumentNullException.");
}
}
开发者ID:Division42LLC,项目名称:Division42.Data.Repository.EntityFramework,代码行数:10,代码来源:EntityFrameworkRepositoryBaseTests.cs
示例2: GetAllWithNoSubItems_ReturnsExpected
public void GetAllWithNoSubItems_ReturnsExpected()
{
using (CustomerRepository repository = new CustomerRepository())
{
IEnumerable<Customer> customers =
repository.GetAll();
Assert.IsNotNull(customers.First());
Assert.IsNull(customers.First().CustomerSecure);
Assert.IsNull(customers.First().Orders);
}
}
开发者ID:Division42LLC,项目名称:Division42.Data.Repository.EntityFramework,代码行数:12,代码来源:EntityFrameworkRepositoryBaseTests.cs
示例3: Main
static void Main()
{
var repository = new CustomerRepository();
var premiumCustomers = repository.GetPremiumCustomers();
var discountVisitor = new DiscountRaiseVisitor();
foreach (var premiumCustomer in premiumCustomers)
{
premiumCustomer.Accept(discountVisitor);
}
var allCustomers = repository.GetAll();
var freePurchaseVisitor = new FreePurchaseVisitor();
foreach (var customer in allCustomers)
{
customer.Accept(freePurchaseVisitor);
}
}
示例4: GetAllWithPredicates_Customer_Succeed
public void GetAllWithPredicates_Customer_Succeed()
{
//Arrange
using (var context = new ManagementContext())
{
var executor = new SqlExecutor(context.Database.Connection.ConnectionString);
executor.ExecuteScript(Path.Combine(Environment.CurrentDirectory, "Scripts", "2 - Customers.sql"));
var unitOfWork = new DatabaseUnitOfWork(context);
var customerRepository = new CustomerRepository(unitOfWork);
//Act
var predicates = CustomerRepository.Predicates(p => p.Id > 2, p => p.Code.StartsWith("A"));
var total = customerRepository.GetAll<Customer>(predicates, null, null).Count();
//Assert
Assert.AreEqual(3, total);
}
}
示例5: GetAllWithPredicate_Customer_Succeed
public void GetAllWithPredicate_Customer_Succeed()
{
//Arrange
InsertCustomers(20);
using (var context = new ManagementContext())
{
var unitOfWork = new DatabaseUnitOfWork(context);
var customerRepository = new CustomerRepository(unitOfWork);
//Act
var total = customerRepository.GetAll(CustomerRepository.Predicates(p => p.Id > 5), null).Count();
//Assert
Assert.AreEqual(15, total);
}
}
示例6: GetAll_Customer_Succeed
public void GetAll_Customer_Succeed()
{
//Arrange
InsertCustomers(20);
using (var context = new ManagementContext())
{
var unitOfWork = new DatabaseUnitOfWork(context);
var customerRepository = new CustomerRepository(unitOfWork);
//Act
var total = customerRepository.GetAll().Count();
//Assert
Assert.AreEqual(20, total);
}
}
示例7: GetGridData
public static object GetGridData(JqGridRequest jqGridRequest)
{
var repo = new CustomerRepository();
IEnumerable<Customer> customers;
var criteria = new List<Func<Customer, bool>>();
if (jqGridRequest.IsSearch)
{
foreach (var rule in jqGridRequest.Where.rules)
{
var userData = rule.data.ToLower();
if (rule.field == "Id")
{
criteria.Add(x => x.Id.ToString() == userData);
}
if (rule.field == "Firstname")
{
criteria.Add(x => x.Firstname.ToLower().Contains(userData));
}
if (rule.field == "Lastname")
{
criteria.Add(x => x.Lastname.ToLower().Contains(userData));
}
if (rule.field == "Email")
{
criteria.Add(x => x.Email.ToLower().Contains(userData));
}
if (rule.field == "DateOfBirth")
{
criteria.Add(x => x.DateOfBirth.ToString().ToLower().Contains(userData));
}
if (rule.field == "City")
{
criteria.Add(x => x.City.ToLower().Contains(userData));
}
}
}
switch (jqGridRequest.SortIndex)
{
case "Id":
customers = repo.GetAll(criteria, jqGridRequest.PageIndex - 1, jqGridRequest.PageSize, x => x.Id, jqGridRequest.SortOrder);
break;
case "Firstname":
customers = repo.GetAll(criteria, jqGridRequest.PageIndex - 1, jqGridRequest.PageSize, x => x.Firstname, jqGridRequest.SortOrder);
break;
case "Lastname":
customers = repo.GetAll(criteria, jqGridRequest.PageIndex - 1, jqGridRequest.PageSize, x => x.Lastname, jqGridRequest.SortOrder);
break;
case "Email":
customers = repo.GetAll(criteria, jqGridRequest.PageIndex - 1, jqGridRequest.PageSize, x => x.Email, jqGridRequest.SortOrder);
break;
case "DateOfBirth":
customers = repo.GetAll(criteria, jqGridRequest.PageIndex - 1, jqGridRequest.PageSize, x => x.DateOfBirth, jqGridRequest.SortOrder);
break;
case "City":
customers = repo.GetAll(criteria, jqGridRequest.PageIndex - 1, jqGridRequest.PageSize, x => x.City, jqGridRequest.SortOrder);
break;
default:
customers = repo.GetAll(criteria, jqGridRequest.PageIndex - 1, jqGridRequest.PageSize, x => x.Id, jqGridRequest.SortOrder);
break;
}
var totalCustomers = repo.GetAll(criteria).Count();
return new
{
total = (totalCustomers / jqGridRequest.PageSize) + ((totalCustomers % jqGridRequest.PageSize > 0) ? 1 : 0),
page = jqGridRequest.PageIndex,
records = totalCustomers,
rows = (
from c in customers
select new Dictionary<string, string>
{
{"Id", c.Id.ToString() }, // Id must always be specified!!
{"Firstname", c.Firstname},
{"Lastname", c.Lastname},
{"Email", c.Email},
{"DateOfBirth", c.DateOfBirth.ToShortDateString()},
{"City", c.City}
}).ToArray()
};
}
示例8: UseObjectAfterDisposed_ThrowsException
public void UseObjectAfterDisposed_ThrowsException()
{
CustomerRepository repository = new CustomerRepository();
repository.Dispose();
repository.GetAll();
Assert.Fail("Should have thrown an ObjectDisposedException.");
}
开发者ID:Division42LLC,项目名称:Division42.Data.Repository.EntityFramework,代码行数:9,代码来源:EntityFrameworkRepositoryBaseTests.cs
示例9: CustomerRepositoryGetAllReturnMaterializedAllItems
public void CustomerRepositoryGetAllReturnMaterializedAllItems()
{
//Arrange
var unitOfWork = new MainBCUnitOfWork();
var customerRepository = new CustomerRepository(unitOfWork);
//Act
var allItems = customerRepository.GetAll();
//Assert
Assert.IsNotNull(allItems);
Assert.IsTrue(allItems.Any());
}