当前位置: 首页>>代码示例>>C#>>正文


C# EFRepository类代码示例

本文整理汇总了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
             }
         }
     });
 }
开发者ID:jnystrom,项目名称:migrainetracker,代码行数:34,代码来源:UnitTest1.cs

示例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"));
        }
开发者ID:Panya911,项目名称:system-of-financial-vote,代码行数:7,代码来源:GenericRepositoryTests.cs

示例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);
 }
开发者ID:Nimrodda,项目名称:TravelersAround,代码行数:7,代码来源:MessageServiceIntegrationTest.cs

示例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);
 }
开发者ID:Nimrodda,项目名称:TravelersAround,代码行数:7,代码来源:MessageServiceIntegrationTest.cs

示例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);
 }
开发者ID:ravdin,项目名称:EntitiesCoreFramework,代码行数:7,代码来源:RepositoryTest.cs

示例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);
 }
开发者ID:Nimrodda,项目名称:TravelersAround,代码行数:7,代码来源:MessageServiceIntegrationTest.cs

示例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"));
            }
        }
开发者ID:jordanyaker,项目名称:ncommon,代码行数:34,代码来源:EFRepositoryQueryTests.cs

示例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);
 }
开发者ID:jmptrader,项目名称:WebFrameworkMVC,代码行数:8,代码来源:EFRepositoryExtensionsTest.cs

示例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());
 }
开发者ID:jnystrom,项目名称:migrainetracker,代码行数:8,代码来源:UnitTest1.cs

示例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();
        }
开发者ID:erdonet,项目名称:GofPatterns,代码行数:58,代码来源:Program.cs

示例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);
   }
开发者ID:nikolasx,项目名称:R2.DisasterWebAPI,代码行数:9,代码来源:ComprehensiveServiceTest.cs

示例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);
        }
开发者ID:jmptrader,项目名称:WebFrameworkMVC,代码行数:9,代码来源:EFRepositoryExtensionsTest.cs

示例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);
 }
开发者ID:nikolasx,项目名称:R2.DisasterWebAPI,代码行数:9,代码来源:GeoHazComprehensiveControllerTest.cs

示例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);
 }
开发者ID:DiscoDancer,项目名称:Study,代码行数:10,代码来源:EFData.cs

示例15: AddEmployee

        public static bool AddEmployee(Employees NewEmployee)
        {
            EFRepository<Employees> EmployeesRepo = new EFRepository<Employees>();

            EmployeesRepo.Add(NewEmployee);

            GlobalUnitOfWork.Commit();
            return true;

        }
开发者ID:GruppoReti,项目名称:GruppoReti.DAL,代码行数:10,代码来源:EmployeeManager.cs


注:本文中的EFRepository类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。