本文整理汇总了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);
}
示例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();
*/
}
示例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);
}
示例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();
}
示例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);
}
示例6: ShouldDeleteAProduct
public void ShouldDeleteAProduct()
{
var productRepository = new ProductRepository(@"Repository\Products.txt", "Product");
productRepository.Delete(2);
Assert.AreEqual(2,productRepository.GetAll().Count());
}
示例7: ViewProduct
public ViewProduct(string fullPath, string tabelName)
{
var repository = new ProductRepository(fullPath, tabelName);
this.products = repository.GetAll();
}
示例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());
}
示例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
}