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


C# ProductRepository.GetAll方法代码示例

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


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

示例1: ShouldUpdateTheStockForProduct

 public void ShouldUpdateTheStockForProduct()
 {
     var productRepository = new ProductRepository(@"Repository\Products.txt", "Product");
        // productRepository.UpdateStock(2);
     var products = productRepository.GetAll().ToArray();
     Assert.AreEqual(2, products[1].Stock);
 }
开发者ID:florentinac,项目名称:repository,代码行数:7,代码来源:ProductRepository.Tests.cs

示例2: Update_Product0_name_to_nill

        public void Update_Product0_name_to_nill()
        {

            
            AutoMapper.Mapper.CreateMap<DataAvail.UralAppModel.Product, Product>()
                .ForMember(p => p.id, opt => opt.MapFrom(p => p.Id))
                .ForMember(p => p.name, opt => opt.MapFrom(p => p.Name));

            AutoMapper.Mapper.CreateMap<Product, DataAvail.UralAppModel.Product>()
                .ForMember(p => p.Id, opt => opt.MapFrom(p => p.id))
                .ForMember(p => p.Name, opt => opt.MapFrom(p => p.name));

            Product product = new Product { id = 0, name = "hip" };

            using (var model = new UralAppModel.Model())
            {
                ProductRepository repo = new ProductRepository();

                repo.SetContext(model);

                repo.GetAll(new Microsoft.Data.Services.Toolkit.QueryModel.ODataQueryOperation());

                repo.Save(product);
            }


            /*
            UralAppServ.DataServiceProvider prr = new UralAppServ.DataServiceProvider(new Uri(@"http://localhost:3360/Service.svc/"));
            var r = prr.Products.Where(p => p.id == 0).First();
            r.name = "nill";
            //prr.AttachTo("Products", r);
            prr.UpdateObject(r);
            prr.SaveChanges();
             */
        }
开发者ID:data-avail,项目名称:DataAvail.Framework,代码行数:35,代码来源:UralAppServiceTest.cs

示例3: ShouldUpdateAProduct

 public void ShouldUpdateAProduct()
 {
     var productRepository = new ProductRepository(@"Repository\Products.txt", "Product");
     productRepository.Update(2,new Product
     {
         Category = "Fruits",
         Name = "Appel",
         Price = 12,
         Stock = 3
     });
     var products = productRepository.GetAll().ToArray();
     Assert.AreEqual("Appel",products[1].Name);
 }
开发者ID:florentinac,项目名称:repository,代码行数:13,代码来源:ProductRepository.Tests.cs

示例4: Main

        public async Task Main(string[] args)
		{
			_prodrepo = new Demo_core.Repositories.ProductRepository();
	        var x = _prodrepo.GetAll();

			const int startId = 300;
			const int endId = 400;
			const int batchSize = 10;
			var n = endId - startId + 1;

			var batches = new List<Tuple<int, int>>();

			for (int i = startId; i < endId; i += batchSize)
			{
				var end = (i + batchSize - 1) > endId ? endId : (i + batchSize - 1);
                batches.Add(new Tuple<int, int>(i, end));
				Debug.WriteLine("batch: " + i +" : " + (i + batchSize -1));
			}

			foreach (var batch in batches)
			{
				var Tasks = new Task[batchSize];
				for (var index = batch.Item1; index <= batch.Item2; index++)
				{
					Debug.WriteLine("scraping: " + index);
					await Scrape(index); //can async later
					//Debug.WriteLine("Adding ID: " + (index).ToString() + " to que");
					//Tasks[index - batch.Item1] = Scrape(index);
				}
				//await Task.WhenAll(Tasks);
				//Debug.WriteLine("===============\ncompleted batch " + batch.Item1 + " : " + batch.Item2 + "\n===============");
				//Debug.WriteLine("Failed:\t\t\t" + failedScrapes + "\nNetworkErrors:\t" + failedNetwork + "\n");
			}
			Debug.WriteLine("===============\nall batches completed\n===============");



			Console.ReadLine();
		}
开发者ID:kfwls,项目名称:drunkr,代码行数:39,代码来源:Program.cs

示例5: Execution_deletes_product_and_associated_inventory_items

        public void Execution_deletes_product_and_associated_inventory_items()
        {
            var orderProxy = new Mock<IOrderDataProxy>();
            orderProxy.Setup(proxy => proxy.GetByProduct(1)).Returns(Enumerable.Empty<Order>());

            var product = new Product() { ProductID = 1 };
            var productDataProxy = new ProductRepository();
            productDataProxy.Clear();
            productDataProxy.Insert(product);

            var inventoryDataProxy = new InventoryItemRepository();
            inventoryDataProxy.Clear();
            inventoryDataProxy.Insert(new InventoryItem() { ProductID = 1 });

            var command = new DeleteProductCommand(1, productDataProxy,
                                                      new InventoryItemService(inventoryDataProxy), 
                                                      orderProxy.Object,
                                                      new TransactionContextStub());
            var result = command.Execute();
            result.Success.ShouldBe(true);
            result.Errors.ShouldBe(null);
            productDataProxy.GetAll().Count().ShouldBe(0);
            inventoryDataProxy.GetAll().Count().ShouldBe(0);
        }
开发者ID:peasy,项目名称:Samples,代码行数:24,代码来源:DeleteProductCommandTests.cs

示例6: ShouldDeleteAProduct

 public void ShouldDeleteAProduct()
 {
     var productRepository = new ProductRepository(@"Repository\Products.txt", "Product");
     productRepository.Delete(2);
     Assert.AreEqual(2,productRepository.GetAll().Count());
 }
开发者ID:florentinac,项目名称:repository,代码行数:6,代码来源:ProductRepository.Tests.cs

示例7: ViewProduct

 public ViewProduct(string fullPath, string tabelName)
 {
     var repository = new ProductRepository(fullPath, tabelName);
     this.products = repository.GetAll();
 }
开发者ID:florentinac,项目名称:repository,代码行数:5,代码来源:ViewProduct.cs

示例8: ProductRepositoryGetAllReturnMaterializedAllItems

      public void ProductRepositoryGetAllReturnMaterializedAllItems()
      {
         //Arrange
         var unitOfWork = new MainBcUnitOfWork();
         IProductRepository productRepository = new ProductRepository(unitOfWork);

         //Act
         var allItems = productRepository.GetAll();

         //Assert
         Assert.IsNotNull(allItems);
         Assert.IsTrue(allItems.Any());
      }
开发者ID:MyLobin,项目名称:NLayerAppV2,代码行数:13,代码来源:ProductRepositoryTests.cs

示例9: 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


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