本文整理汇总了C#中EFRepository类的典型用法代码示例。如果您正苦于以下问题:C# EFRepository类的具体用法?C# EFRepository怎么用?C# EFRepository使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EFRepository类属于命名空间,在下文中一共展示了EFRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertUserTest
public void InsertUserTest()
{
EFRepository<GazallionMigraineDataDbContext> repo = new EFRepository<GazallionMigraineDataDbContext>();
User test = repo.Insert<User>(new User
{
FirstName = "John",
LastName = "Nystrom",
Addresses = new List<Address>
{
new Address
{
City = "Alpharetta",
Region = "GA",
ZipCode = "30004",
StreetName = "Montgomery Ave",
StreetNumber = "123"
}
},
EmailAddress = "[email protected]",
UserConditions = new List<UserCondition>
{
new UserCondition
{
Condition = new Condition
{
Name = "Migraine",
Description = "bad headaches"
},
IncidentThreshold = 9,
ThresholdTimePeriod = (int)ThresholdTimePeriod.Monthly
}
}
});
}
示例2: addElement
public void addElement()
{
var repository = new EFRepository<User>(new SystemOfFinancialContext());
repository.Insert(new User(){FirstName = "Flyagin"});
Assert.NotNull(repository.Get(x=>x.FirstName=="Flyagin"));
}
示例3: ReadMessageTest
public void ReadMessageTest()
{
IRepository repo = new EFRepository();
MessageService ms = new MessageService(repo);
var message = ms.ReadMessage(new Guid("c085ce65-9fd8-e011-813c-206a8a339500"), new Guid("37519c07-acd4-e011-ad03-206a8a339500"));
Assert.IsNotNull(message);
}
示例4: ReadMessage_With_Invalid_MessageID
public void ReadMessage_With_Invalid_MessageID()
{
IRepository repo = new EFRepository();
MessageService ms = new MessageService(repo);
var message = ms.ReadMessage(new Guid("11111111-1111-1111-1111-111111111111"), new Guid("37519c07-acd4-e011-ad03-206a8a339500"));
Assert.IsNotNull(message);
}
示例5: Setup
public void Setup()
{
var mockDbSet = new MockDbSet<FakeEntity>(TestData.GetFakeEntities());
_mockDbContext = new Mock<IDbContext>();
_mockDbContext.Setup(m => m.Set<FakeEntity>()).Returns(mockDbSet);
_testRepository = new EFRepository<FakeEntity>(_mockDbContext.Object);
}
示例6: ReadMessage_With_Invalid_TravelerID
public void ReadMessage_With_Invalid_TravelerID()
{
IRepository repo = new EFRepository();
MessageService ms = new MessageService(repo);
var message = ms.ReadMessage(new Guid("c085ce65-9fd8-e011-813c-206a8a339500"), new Guid("11111111-1111-1111-1111-111111111111"));
Assert.IsNotNull(message);
}
示例7: Can_attach_modified_entity
public void Can_attach_modified_entity()
{
var customer = new Customer
{
FirstName = "John",
LastName = "Doe"
};
var context = (OrderEntities) OrdersContextProvider();
context.AddToCustomers(customer);
#if EF_1_0
context.SaveChanges(true);
#else
context.SaveChanges(SaveOptions.AcceptAllChangesAfterSave);
#endif
context.Detach(customer);
context.Dispose();
using (var scope = new UnitOfWorkScope())
{
customer.LastName = "Changed";
var repository = new EFRepository<Customer>();
repository.Attach(customer);
scope.Commit();
}
using (var testData = new EFTestData(OrdersContextProvider()))
{
Customer savedCustomer = null;
testData.Batch(x => savedCustomer = x.GetCustomerById(customer.CustomerID));
Assert.That(savedCustomer, Is.Not.Null);
Assert.That(savedCustomer.LastName, Is.EqualTo("Changed"));
}
}
示例8: Can_fetch_after_a_many_fetch
public void Can_fetch_after_a_many_fetch()
{
var repository = new EFRepository<Order,int>();
var fetchingRepo = repository
.FetchMany(x => x.OrderItems)
.ThenFetch(x => x.Product);
Assert.AreEqual("OrderItems.Product", fetchingRepo.FetchingPath);
}
示例9: TestMethod1
public void TestMethod1()
{
IRepository repo = new EFRepository<GazallionMigraineDataDbContext>();
IUserService userService = new UserService(repo);
var users = userService.GetUsers();
Assert.IsNotNull(users);
Assert.IsTrue(users.Any());
}
示例10: Main
static void Main(string[] args)
{
EFRepository<Product> productRepository = new EFRepository<Product>();
LoggingRepositoryDecorator<Product> updateDeleteLoggingDecorator =
new LoggingRepositoryDecorator<Product>(productRepository);
SendRequestRepositoryDecorator<Product> updateDeleteRequestDecorator =
new SendRequestRepositoryDecorator<Product>(updateDeleteLoggingDecorator);
UpdateDataWareHouseRepositoryDecorator<Product> updateDataWareHouseDecorator =
new UpdateDataWareHouseRepositoryDecorator<Product>(updateDeleteRequestDecorator);
SecurityRepositoryDecorator<Product> securityDecorator =
new SecurityRepositoryDecorator<Product>(updateDataWareHouseDecorator);
#region Select işlemi
Console.WriteLine("--------------------------------------------");
securityDecorator.Get(3);
Console.WriteLine("---------------------------------------------\n");
#endregion
#region Add işlemi
Console.WriteLine("--------------------------------------------");
Product p=new Product(){ ProductId=1, ProductName="Ürünüm 1" };
securityDecorator.Add(p);
Console.WriteLine("---------------------------------------------\n");
#endregion
#region Update ve Delete İşlemi
Console.WriteLine("---------------------------------------------");
securityDecorator.Delete(p);
Console.WriteLine("---------------------------------------------\n");
Console.WriteLine("---------------------------------------------");
securityDecorator.Update(p);
Console.WriteLine("---------------------------------------------\n");
#endregion
Console.ReadLine();
}
示例11: Test_QueryByUnifieldId
public void Test_QueryByUnifieldId()
{
IDbContext db = new R2DisasterContext();
IRepository<Comprehensive> re = new EFRepository<Comprehensive>(db);
IComprehensiveService service = new ComprehensiveService(re);
string id = "370101060001";
Comprehensive c=service.GetByUnifiedID(id);
}
示例12: Can_fectch_many_on_association
public void Can_fectch_many_on_association()
{
var repository = new EFRepository<Order,int>();
var fetchingRepo = repository
.Fetch(order => order.Customer)
.ThenFetchMany(customer => customer.Orders);
Assert.AreEqual("Customer.Orders", fetchingRepo.FetchingPath);
}
示例13: TestGetByUIdCanNotBeNull
public void TestGetByUIdCanNotBeNull()
{
IDbContext db = new R2DisasterContext();
IRepository<Comprehensive> re = new EFRepository<Comprehensive>(db);
IComprehensiveService s = new ComprehensiveService(re);
InvestigationController c = new InvestigationController(s);
string a=null;
c.GetCompleteByUId(a);
}
示例14: Reload
public void Reload()
{
_context = new TMPHWEntities();
EMP = new EFRepository<EMP>(_context);
DEPT = new EFRepository<DEPT>(_context);
DEMO_CUSTOMERS = new EFRepository<DEMO_CUSTOMERS>(_context);
DEMO_ORDERS = new EFRepository<DEMO_ORDERS>(_context);
DEMO_ORDER_ITEMS = new EFRepository<DEMO_ORDER_ITEMS>(_context);
DEMO_PRODUCT_INFO = new EFRepository<DEMO_PRODUCT_INFO>(_context);
}
示例15: AddEmployee
public static bool AddEmployee(Employees NewEmployee)
{
EFRepository<Employees> EmployeesRepo = new EFRepository<Employees>();
EmployeesRepo.Add(NewEmployee);
GlobalUnitOfWork.Commit();
return true;
}