本文整理匯總了C#中System.Item.Save方法的典型用法代碼示例。如果您正苦於以下問題:C# Item.Save方法的具體用法?C# Item.Save怎麽用?C# Item.Save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Item
的用法示例。
在下文中一共展示了Item.Save方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CreateRetrieveUpdateDelete
public void CreateRetrieveUpdateDelete()
{
string sku = DateTime.Now.ToString( "MMddHHmm" );
string name = string.Format( "test item - {0}", DateTime.Now.ToString( "MMdd HHmm" ) );
// create test
Item item = new Item();
item.Sku = sku;
item.Name = name;
item.Save();
// retrieve test
item = Item.Retrieve( sku );
Assert.AreEqual( name, item.Name );
// update test
item.Name += " update test";
item.Save();
// delete test
item.Delete();
}
示例2: ManyToOneTest
public void ManyToOneTest()
{
Item Temp = new Item();
Temp.Name = "Parent";
for (int x = 0; x < 5; ++x)
{
Item Child = new Item();
Child.Name = "Child "+x.ToString();
Child.Parent=Temp;
Temp.Children.Add(Child);
}
Temp.Save();
Item Parent = Item.Any(new EqualParameter<long>(Temp.ID, "ID_"));
foreach (Item Child in Parent.Children)
Assert.Equal(Parent, Child.Parent);
Assert.Equal(5, Parent.Children.Count);
Assert.Equal(null, Parent.Parent);
Parent.Children = Parent.Children.Remove(x => x.Name == "Child 0").ToList();
Parent.Save();
Parent = Item.Any(new EqualParameter<long>(Temp.ID, "ID_"));
foreach (Item Child in Parent.Children)
Assert.Equal(Parent, Child.Parent);
Assert.Equal(4, Parent.Children.Count);
Assert.Equal(null, Parent.Parent);
Parent.Delete();
Parent = Item.Any(new EqualParameter<long>(Temp.ID, "ID_"));
Assert.Null(Parent);
Assert.Equal(1, Item.All().Count());
}
示例3: CreateInvalidItem
public void CreateInvalidItem()
{
Item item = new Item();
item.Name = "Bad Item";
item.Save();
}