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


C# ProductRepository.Remove方法代码示例

本文整理汇总了C#中ProductRepository.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# ProductRepository.Remove方法的具体用法?C# ProductRepository.Remove怎么用?C# ProductRepository.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProductRepository的用法示例。


在下文中一共展示了ProductRepository.Remove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OrderRepositoryRemoveItemDeleteIt

        public void OrderRepositoryRemoveItemDeleteIt()
        {
            //Arrange
            var unitOfWork = new MainBCUnitOfWork();
            IProductRepository productRepository = new ProductRepository(unitOfWork);

            var book = new Book()
            {
                Id = IdentityGenerator.NewSequentialGuid(),
                ISBN = "ABC",
                Publisher = "Krasiss Press",
                Title = "The book title",
                UnitPrice = 40,
                Description = "Any book description",
                AmountInStock = 1
            }; ;

            productRepository.Add(book);
            productRepository.UnitOfWork.Commit();

            //Act

            productRepository.Remove(book);
            productRepository.UnitOfWork.Commit();

            var result = productRepository.Get(book.Id);

            //Assert
            Assert.IsNull(result);
        }
开发者ID:gabrielsimas,项目名称:MicrosoftNLayerApp,代码行数:30,代码来源:ProductRepositoryTests.cs

示例2: Clear

        public static void Clear()
        {
            IRepository<Client> _clientRepository = new ClientRepository();
            IRepository<Product> _productRepository = new ProductRepository();
            IRepository<Manager> _managerRepository = new ManagerRepository();

            IEnumerable<Client> clientRepository = _clientRepository.GetItems();
            IEnumerable<Product> productRepository = _productRepository.GetItems();
            IEnumerable<Manager> managerRepository = _managerRepository.GetItems();

            foreach (var item in clientRepository)
            {
                _clientRepository.Remove(item);
            }

            foreach (var item in productRepository)
            {
                _productRepository.Remove(item);
            }

            foreach (var item in managerRepository)
            {
                _managerRepository.Remove(item);
            }
        }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:25,代码来源:ClearDatabase.cs

示例3: RepositoryRemoveTest

 public void RepositoryRemoveTest()
 {
     Program.ClearInformation();
     IRepository<Product> _productRepository = new ProductRepository();
     Product product = new Product(1, "House", "MOPRa,1", "for sale");
     _productRepository.Add(product);
     _productRepository.Remove(product.id);
     Product actual = _productRepository.GetItem(product.id);
     Product expected = null;
     Assert.AreEqual(expected, actual);
     Program.ClearInformation();
 }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:12,代码来源:Tests.cs

示例4: SyncTable_Product

        /// <summary>
        /// Sync logic for product table
        /// </summary>
        private void SyncTable_Product()
        {
            var localTable = new ProductRepository<Product>(_localSessionContext);
            var remoteTable = new ProductRepository<Product>(_remoteSessionContext);

            OnSyncStart?.Invoke(this, new SyncStartedArgs("Product"));

            #region SyncCode

            var count = 0;
            var total = localTable.Count();
            foreach (var row in localTable.GetAll())
            {

                // Copy object and save (this removes ID)
                var newObject = ObjectCopy.Copy(row);
                remoteTable.Save(newObject);

                // Save changes to remote
                remoteTable.Commit();

                // Create a sync record this captures the remote ID value
                // so we can update any relationships...
                var record = new SyncRecord();
                record.Table_Id = "product_table";
                record.Local_Id = row.Id;
                record.Remote_Id = newObject.Id;
                _recordRepository.Save(record);
                _recordRepository.Commit();

                OnUpdateStatus?.Invoke(this, new ProgressEventArgs("Synced entity " + ++count + "/" + total));

                // Remove after successful remove
                localTable.Remove(row);
                localTable.Commit();
            }

            #endregion
        }
开发者ID:looterwar,项目名称:RepositoryResearch,代码行数:42,代码来源:SyncManager.cs

示例5: AutoFilling

        public static void AutoFilling()
        {
            Product[] product = new Product[10];
            Client[] client = new Client[10];
            Manager[] manager = new Manager[10];

            product[0] = new Product(1, "House", "Moskovskaya, 320", "for sale");
            product[1] = new Product(2, "Office", "MOPRa, 30", "for sale");
            product[2] = new Product(3, "House", "Belorusskaya, 10", "for sale");
            product[3] = new Product(4, "Bar", "MOPRa, 3", "for sale");
            product[4] = new Product(5, "House", "Leningradskaya, 35", "for sale");
            product[5] = new Product(6, "Cafe", "Molodogvardeiskaya, 70", "for sale");
            product[6] = new Product(7, "House", "Moskovskaya, 30", "for sale");
            product[7] = new Product(8, "Club", "Zelenaya, 11", "for sale");
            product[8] = new Product(9, "House", "Lugivaja, 11", "for sale");
            product[9] = new Product(10, "Pizzeria", "Pionerskaya, 4", "for sale");

            client[0] = new Client(1, "Fedor Dvinyatin");
            client[1] = new Client(2, "Alexei Volkov");
            client[2] = new Client(3, "Ivan Ivanov");
            client[3] = new Client(4, "Petr Bojko");
            client[4] = new Client(5, "Egor Valedinsky");
            client[5] = new Client(6, "Alexander Evtuh");
            client[6] = new Client(7, "Alexei Lohnitsky");
            client[7] = new Client(8, "Mokin Alexander");
            client[8] = new Client(9, "Pavlovets Sergey");
            client[9] = new Client(10, "Igor Pujko");

            manager[0] = new Manager(1, "Viktor Oniskevich");
            manager[1] = new Manager(2, "Petr Glinskij");
            manager[2] = new Manager(3, "Fedor Yakubuk");
            manager[3] = new Manager(4, "Vasily Sapon");
            manager[4] = new Manager(5, "Igor Ivanovskiy");
            manager[5] = new Manager(6, "Alexander Dubrovsky");
            manager[6] = new Manager(7, "Olga Golub");
            manager[7] = new Manager(8, "Egor Pirozhkov");
            manager[8] = new Manager(9, "Boris Zhukovich");
            manager[9] = new Manager(10, "Igor Stepanchuk");

            IRepository<Client> _clientRepository = new ClientRepository();
            IRepository<Product> _productRepository = new ProductRepository();
            IRepository<Manager> _managerRepository = new ManagerRepository();

            IEnumerable<Client> clientRepository = _clientRepository.GetItems();
            IEnumerable<Product> productRepository = _productRepository.GetItems();
            IEnumerable<Manager> managerRepository = _managerRepository.GetItems();

            foreach (var item in clientRepository)
            {
                _clientRepository.Remove(item);
            }

            foreach (var item in productRepository)
            {
                _productRepository.Remove(item);
            }

            foreach (var item in managerRepository)
            {
                _managerRepository.Remove(item);
            }

            for (int i = 0; i <= 9; i++)
            {
                _clientRepository.Add(client[i]);
                _productRepository.Add(product[i]);
                _managerRepository.Add(manager[i]);
            }
        }
开发者ID:WilliamRobertMontgomery,项目名称:asp-dot-net-training-project,代码行数:69,代码来源:HomeController.cs


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