本文整理汇总了C#中EFRepository.Count方法的典型用法代码示例。如果您正苦于以下问题:C# EFRepository.Count方法的具体用法?C# EFRepository.Count怎么用?C# EFRepository.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EFRepository
的用法示例。
在下文中一共展示了EFRepository.Count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCountDeleteIsOK
public void GetCountDeleteIsOK()
{
var context = new CarContext();
var testContext = new EFRepository<Car,int>(context);
var all = context.Car.ToList();
all.ForEach(r => testContext.Delete(r));
testContext.Save();
Assert.AreEqual(context.Car.ToList().Count, 0);
context.Car.Add(new Car()
{
CarName = "Ford",
CarPrice = 100000
});
testContext.Save();
var cars = context.Car.ToList();
Assert.AreEqual(testContext.Count(), 1);
Assert.AreEqual(testContext.Get(r => r.CarPrice == 100000).CarName, "Ford");
}
示例2: Can_query_using_specification
public void Can_query_using_specification()
{
var testData = new EFTestData(Context);
testData.Batch(x =>
{
x.CreateCustomer(customer => customer.State = "CA");
x.CreateCustomer(customer => customer.State = "CA");
x.CreateCustomer(customer => customer.State = "PA");
});
using (var scope = new UnitOfWorkScope())
{
var specification = new Specification<Customer>(x => x.State == "CA");
var results = new EFRepository<Customer>()
.Query(specification);
Assert.That(results.Count(), Is.EqualTo(2));
scope.Commit();
}
}