本文整理汇总了C#中Product.CallOnPropertyChanged方法的典型用法代码示例。如果您正苦于以下问题:C# Product.CallOnPropertyChanged方法的具体用法?C# Product.CallOnPropertyChanged怎么用?C# Product.CallOnPropertyChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product.CallOnPropertyChanged方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: When_Adding_EntityType_With_All_Properties_Then_It_Must_Be_Added_To_Server_With_All_Properties
public void When_Adding_EntityType_With_All_Properties_Then_It_Must_Be_Added_To_Server_With_All_Properties()
{
using (var scenario =
new ODataScenario()
.WithProducts(Any.Products())
.Start())
{
var context = GetDataServiceContext(scenario.GetBaseAddress());
context.MergeOption = MergeOption.OverwriteChanges;
var dQuery = context.CreateQuery<Product>("/" + "Products");
var products = context.ExecuteAsync<Product, IProduct>(dQuery).Result;
products.CurrentPage.Count.Should().Be(5);
var newProduct = new Product();
newProduct.Id = 6;
newProduct.Name = Any.CompanyName();
newProduct.Price = Any.Decimal();
newProduct.Category = Any.AlphanumericString();
newProduct.CallOnPropertyChanged("Id");
newProduct.CallOnPropertyChanged("Name");
newProduct.CallOnPropertyChanged("Price");
newProduct.CallOnPropertyChanged("Category");
context.AddObject("Products", newProduct);
context.SaveChangesAsync().Wait();
var updatedProducts = context.ExecuteAsync<Product, IProduct>(dQuery).Result;
updatedProducts.CurrentPage.Count.Should().Be(6);
updatedProducts.CurrentPage[5].Should().BeSameAs(newProduct);
}
}
示例2: using
public void When_Adding_EntityType_With_Partial_Properties_Then_It_Must_Be_Added_To_Server_With_Partial_Properties()
{
using (var scenario =
new ODataScenario()
.WithProducts(Any.Products())
.Start())
{
var context = GetDataServiceContext(scenario.GetBaseAddress());
var dQuery = context.CreateQuery<Product>("/" + "Products");
var products = context.ExecuteAsync<Product, IProduct>(dQuery).Result;
products.CurrentPage.Count.Should().Be(5);
var newProduct = new Product();
string newName = Any.CompanyName();
newProduct.Id = 6;
newProduct.Name = newName;
newProduct.Price = Any.Decimal();
newProduct.Category = Any.AlphanumericString();
// calling 'OnPropertyChanged' only for 'Id' and 'Name' properties
newProduct.CallOnPropertyChanged("Id");
newProduct.CallOnPropertyChanged("Name");
context.AddObject("Products", newProduct);
context.SaveChangesAsync().Wait();
var updatedProducts = context.ExecuteAsync<Product, IProduct>(dQuery).Result;
updatedProducts.CurrentPage.Count.Should().Be(6);
// the 'Id' and 'Name' properties must be set
updatedProducts.CurrentPage[5].Id.Should().Be(6);
updatedProducts.CurrentPage[5].Name.Should().Be(newName);
// the 'Price' and 'Category' properties must not be set
updatedProducts.CurrentPage[5].Price.Should().Be(0);
updatedProducts.CurrentPage[5].Category.Should().BeNull();
}
}