本文整理汇总了C#中IEmployeeRepository.Find方法的典型用法代码示例。如果您正苦于以下问题:C# IEmployeeRepository.Find方法的具体用法?C# IEmployeeRepository.Find怎么用?C# IEmployeeRepository.Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEmployeeRepository
的用法示例。
在下文中一共展示了IEmployeeRepository.Find方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestTransaction_SameContext
public void TestTransaction_SameContext() {
try {
_context.Start();
_employeeRepository.Add( _employee );
throw new Exception();
_departmentRepository.Add( _department );
_context.Commit();
}
catch {
_employeeRepository = Ioc.Create<IEmployeeRepository>();
Assert.IsNull( _employeeRepository.Find( _employee.Id ) );
}
}
示例2: TestRemove_Id
public void TestRemove_Id() {
//添加
_employeeRepository.Add( _employee );
//标识查找
_employeeRepository = Ioc.Create<IEmployeeRepository>();
Assert.IsNotNull( _employeeRepository.Find( _employee.Id ) );
//移除
_employeeRepository.Remove( _employee.Id );
//索引器查找
_employeeRepository = Ioc.Create<IEmployeeRepository>();
Assert.IsNull( _employeeRepository[_employee.Id] );
}
示例3: TestTransaction_DifferentContext_AllFail
public void TestTransaction_DifferentContext_AllFail() {
_departmentRepository = new DepartmentRepository( Helper.GetEfContext() );
try {
using ( TransactionScope scope = new TransactionScope() ) {
_employeeRepository.Add( _employee );
throw new Exception();
_departmentRepository.Add( _department );
scope.Complete();
}
}
catch {
_employeeRepository = Ioc.Create<IEmployeeRepository>();
Assert.IsNull( _employeeRepository.Find( _employee.Id ) );
}
}
示例4: TestUpdate_1
public void TestUpdate_1() {
//添加
_employeeRepository.Add( _employee );
//标识查找
_employeeRepository = Ioc.Create<IEmployeeRepository>();
_employee = _employeeRepository.Find( _employee.Id );
//修改并提交
_employee.Name = "A";
_employeeRepository.Save();
//标识查找
_employeeRepository = Ioc.Create<IEmployeeRepository>();
_employee = _employeeRepository.Find( _employee.Id );
//验证
Assert.AreEqual( "A", _employee.Name );
}
示例5: TestTransaction_AllFail
public void TestTransaction_AllFail() {
try {
using( TransactionScope scope = new TransactionScope() ) {
_context.Start();
_employeeRepository.Add( _employee );
_departmentRepository.Add( _department );
_context.Commit();
throw new Exception();
_employeeRepository2.Add( _employee2 );
scope.Complete();
}
}
catch {
_employeeRepository = Ioc.Create<IEmployeeRepository>();
Assert.IsNull( _employeeRepository.Find( _employee.Id ) );
}
}
示例6: TestTransaction_AllSuccess
public void TestTransaction_AllSuccess() {
using ( TransactionScope scope = new TransactionScope() ) {
_context.Start();
_employeeRepository.Add( _employee );
_departmentRepository.Add( _department );
_context.Commit();
_employeeRepository2.Add( _employee2 );
scope.Complete();
}
_employeeRepository = Ioc.Create<IEmployeeRepository>();
Assert.IsNotNull( _employeeRepository.Find( _employee.Id ) );
_employeeRepository2 = new EmployeeRepository( Helper.GetEfContext2() );
Assert.IsNotNull( _employeeRepository2.Find( _employee2.Id ) );
}
示例7: TestUpdate_2
public void TestUpdate_2() {
//添加
_employeeRepository.Add( _employee );
//创建新对象并附加
_employeeRepository = Ioc.Create<IEmployeeRepository>();
_employee = _employee.Copy();
_employee.Name = "A";
_employeeRepository.Update( _employee );
//标识查找
_employeeRepository = Ioc.Create<IEmployeeRepository>();
_employee = _employeeRepository.Find( _employee.Id );
//验证
Assert.AreEqual( "A", _employee.Name );
}
示例8: TestTransaction_DifferentContext_AllSuccess
public void TestTransaction_DifferentContext_AllSuccess() {
_departmentRepository = new DepartmentRepository( Helper.GetEfContext() );
using ( TransactionScope scope = new TransactionScope() ) {
_employeeRepository.Add( _employee );
_departmentRepository.Add( _department );
scope.Complete();
}
_employeeRepository = Ioc.Create<IEmployeeRepository>();
Assert.IsNotNull( _employeeRepository.Find( _employee.Id ) );
_departmentRepository = Ioc.Create<IDepartmentRepository>();
Assert.IsNotNull( _departmentRepository.Find( _department.Id ) );
}